Button does not execute the javascript below suggested in Javascript best practices

I am using the js below and I am not a Javascript expert. Iam unable to get the button in Storyline 360 to execute the js. I would appreciate any help or expertise on this as I am attempting to generate an email including answers from text entry questions from the learners to the course coordinator.

var email="coursecoordinator@email.com";
var subject="subject line";
var body_start="How you want to begin your body.";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

 

Thanks

Tina

4 Replies
Walt Hamilton

The first thing to check is that you are doing this in a published version, because js does not run in preview.

Next step is to put an alert in the script. - alert("I' here");  Make it the first line of the script. If the script is executed, a message box will show on your screen, If it does, the script is executing; if not, it isn't.

Tina Bridson

I am publishing it to the LMS and then attempting to run the script from the button in storyline 360. I used the code suggested as below:

alert("I' here");
var email="tina.bridson@justice.nsw.gov.au";
var subject="subject line";
var body_start="How you want to begin your body.";
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;
win=window.open(mailto_link,'emailWin');

There is no "alert" message box displayed as suggested in Walt's reply. If the js is not executing I guess I can't use the suggested js in the good practices guide unless I am missing something important.

Thanks

Tina

 

Math Notermans

Only changed alert("I' here"); to alert("I here"); and it works.

Quotation marks are especially tricky in Javascript. One wrong quotation mark at a wrong position and your code fails.

Further there is a problem with calling your default mail programme. Basically this code calls your default mail programme. If that one is not setup correctly or not set up at all..well it will fail. On Windows the default mail handler is Windows own mail tool..as seen in the image below. I use Outlook...so to ensure the code opens up Outlook indeed, you do need to change your default to that.

defaultmailAs you dont have control over your students default email settings...this can go wrong on their end too. I attached the Storyline..

Do test it locally with a publish for Web before you publish for LMS and upload it.

Kind regards,

Math