Forum Discussion
Javascript in Storyline 360
A few fixes to get this working. See the sample on Review...
https://360.articulate.com/review/content/d3c5d2eb-60ea-4474-914e-0cff915b0232/review
You need to be aware though that you have a proper default mail-client set on your computer...as that is what will be used. With Javascript you cannot test whether a user has a default mail client installed. If a user has not, 'mailto:' always fails.
This code works.var player = GetPlayer();
var email = "email@company.com";
var user = player.GetVar("UserName") ;
var text = player.GetVar("CalculatorText") ;
var subject = "Calculator quiz response" ;
console.log("mailto: "+user+" | "+text)
var emailBody = "The response for "+escape('\r\n') + user + " is: "+escape('\r\n')+"text";
var mailto_link = 'mailto: '+email+'?subject='+subject+'&body='+emailBody;
win = window.open(mailto_link, 'emailWin') ;
Notice the differences with your code...
GetPlayer instead of GetPLayer.
Javascript is picky about capitals.
The emailbody line uses escape('\r\n')
and that part of code isnot included in a string... its outside the string. No need for encodeURIComponent
as escape already does that.
And here you have a complete working sample. Do use a external editor like Sublime Text or Brackets to edit your code. The Storyline ide doesnot show errors and really is no good. The tools mentioned all have colorcoding, hints and code checking. Makes life so much easier.
Kind regards,
Math
- CindyBartrop-5d4 years agoCommunity Member
Thanks so much - once I removed the quotation marks around "text", it worked perfectly!
Cheers,
Cindy Bartrop
Instructional Designer/
Documentation LeadrVox: 121-5608
direct: +1.778.331.5608
mobile: +1.604.315.6529
email: cbartrop@rbauction.com9500 Glenlyon Parkway
Burnaby, BC, CA V5J 0C6[cid:image001.png@01D7C5CD.CCD35B10]
Our Safety Commitment:
to send everyone home, every day,
the way they came to work[Macintosh HD:Users:seabay:Desktop:f-ogo