Javascript Help Needed with Storyline Course

Mar 28, 2017

Hello! I recently found this beautiful javascript code which allows me to gather all kinds of variables from a course and then email those variables to the learner. These are notes they take while typing into textboxes within the course. The code works beautifully with one exception - the last line of code opens a window and then emails all of the variables I've gathered throughout the elearning course. So I end up with my elearning course open in one browser tab and another blank browser tab open on top of it. I would like to add a line of code that closes that blank tab once the email is initiated so that the user doesn't need to manually close it. Can anyone please tell me how to do this? Thanks in advance! Here's the code:

var player = GetPlayer();
var useremail=player.GetVar("email");
var subject="Using the ABC Model to Overcome Objections";

var exercisenotes1=player.GetVar("benefits");
var exercisenotes2=player.GetVar("benefits2");
var exercisenotes3=player.GetVar("ASK1");
var exercisenotes4=player.GetVar("BENEFIT1");
var exercisenotes5=player.GetVar("givenask11");
var exercisenotes6=player.GetVar("givenbenefits11");
var exercisenotes7=player.GetVar("givenconfirm1");

var mailto_link='mailto:'+useremail+'?subject='+subject+'&body='+"OBJECTION I MAY HEAR:%0d%0A"+exercisenotes1+"%0d%0A%0d%0AWORDS I CAN SAY USING THE ABC MODEL:%0d%0A"+exercisenotes2+"%0d%0A%0d%0A"+exercisenotes3+"%0d%0A%0d%0A"+exercisenotes4+"%0d%0A%0d% 0AABC MODEL NOTES:%0d%0A"+exercisenotes5+"%0d%0A%0d%0A"+exercisenotes6+"%0d%0A%0d%0A"+exercisenotes7;,'emailWin');

4 Replies
Joe Schultz

I researched it and the iframe thing won't work because you can't evoke an iframe using javascript.

However, I did find some javascript that would close the extra window. The relevant lines are the last two:

var player = GetPlayer();
var email=player.GetVar("email");
var subject="My Subject";
var body_start=player.GetVar("notes");
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+escape(body_start);,'emailWin');

Note: "email" and "notes" are variables set up in Storyline.

This discussion is closed. You can start a new discussion or contact Articulate Support.