Forum Discussion
User notes that they can print and email
In my example, those are the names of Javascript variables that are created by the script and are used to contain the values of various StoryLine variables. I don't remember if it is the same in Stephanie's example but I believe that it is.
The code can basically be split into several sections:
// Opens a new window for printing
myWindow = window.open("","Print","width=810,height=610,scrollbars=1,resizable=1");
// Launches the javascript function to get variable values. Gets storyline variables and assigns them to a java variable. The first part (before the =) is the new java variable. The second part (after the =) is a call to storyline to get the value from the specified storyline variable.
var player=GetPlayer();
var headline=player.GetVar("PrintTitle");
var date=player.GetVar("SystemDate");
var exercisenotes1=player.GetVar("NotesOne");
var exercisenotes2=player.GetVar("NotesTwo");
// Creates a java variable called contents and assigns it with html content. The html content controls how and where the content appears in the print window. It includes the java variables that you just created and assigned storyline values to.
var contents = "< html><head></head><body style='width:650px;padding:20px;'>"
contents+="< div style='font-size:22px;font-weight:bold;margin-top:20px;margin-bottom:20px;'>"+headline+"</div>";
contents+="< div style='font-size:16px;'>"+date+"</div>";
contents+="< div style='font-size:18px;font-weight:bold;margin-top:10px;'>Activity Notes 1</div>";
contents+="< div style='font-size:17px;margin-top:5px;'>"+exercisenotes1+"</div>";
contents+="< div style='font-size:18px;font-weight:bold;margin-top:10px;'>Activity Notes 2</div>";
contents+="< div style='font-size:17px;margin-top:5px;'>"+exercisenotes2+"</div>";
contents+="< /body></html>"
// Writes the html to the window and initiates the print function
myWindow.document.write(contents);
myWindow.document.close();
myWindow.focus();
myWindow.print();