Forum Discussion
JavaScript to email and print a slide in Storyline 360
Hi, I am trying to email and print a slide in my storyline project and neither of them are working. Here is the code I am using.
Email:
var player = GetPlayer();
var email=player.GetVar("TextEntry12");
var subject="My Strategy Team";
var visionaries=player.GetVar("Visionaries");
var problemsolvers=player.GetVar("ProblemSolvers");
var doers=player.GetVar("Doers");
var mailto_link='mailto:'+email+'?subject='+subject+'&body='+"My Strategy Team - Visionaries:%0d%0A"+visionaries+"%0d%0A%0d%0AMy Strategy Team – Problem-Solvers:%0d%0A"+problemsolvers+"%0d%0A%0d%0AMy Strategy Team – Doers:%0d%0A"+doers;
win=window.open(mailto_link,'emailWin');
Print:
var myWindow = window.open("","Print","width=810,height=610,scrollbars=1,resizable=1");
var headline=player.GetVar("PrintTitle");
var usernotes=player.GetVar("notes");
var visionaries=player.GetVar("Visionaries");
var problemsolvers=player.GetVar("ProblemSolvers");
var doers=player.GetVar("Doers");
var contents = "<html><head></head><body style='width:650px;padding:20px;'>"
contents+= "<div style='height:20px;padding:10px;margin-bottom:20px;text-align:center;'><button onclick='javascript:window.print();'>Print My Notes</button></div>";
contents+="<div style='font-size:18px;font-weight:bold;margin-top:10px;'>Visionaries</div>";
contents+="<div style='font-size:17px;margin-top:5px;'>"+visionaries+"</div>";
contents+="<div style='font-size:18px;font-weight:bold;margin-top:10px;'>Problem-Solvers</div>";
contents+="<div style='font-size:17px;margin-top:5px;'>"+problemsolvers+"</div>";
contents+="<div style='font-size:18px;font-weight:bold;margin-top:10px;'>Doers</div>";
contents+="<div style='font-size:17px;margin-top:5px;'>"+doers+"</div>";
contents+= "</body></html>"
myWindow.document.write(contents);
I do not know a lot about JavaScript. Any suggestions?
- JessicaDavis-37Community Member
Hey! I have a very similar question. Were you ever able to find an answer?
- WaltHamiltonSuper Hero
Can you be a little more specific with your question?
- JessicaDavis-37Community Member
Hey @Walt! I'm curious to get your take on a similar question - https://community.articulate.com/discussions/articulate-storyline/storyline-printing-learner-text-with-javascript-question
- MathNotermans-9Community Member
Please share a sample Storyline with these kind of questions.
- WaltHamiltonSuper Hero
I think Sandeep was probably correct. In the third picture, where the red line is, there is a Carriage Return (Enter or Return was pressed). I don’t know if it was put there during original creation, or the copying process, or when, but it is the culprit. JS recognizes a Carriage Return as starting a new command.
- AyseSahin-3327fCommunity Member
Hello,
Here is the solution (in attachment the story file)
Please remember you have to publish in the scorm format to see the results.
If you just preview the module, you won't be able to execute the Javascript.Here are 3 variables :
useremail
TextEntry1
TextEntry2"The GetVAR command then takes those variables from the project and redefines them as variables in the Javascript."