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
How can I add several text entries from the eLearning to the same mail using the javascript?