Passing variables to certificate (in HTML5 version)
May 27, 2015
Since Storyline (1) does not support Print Results in HTML5 mode I decided to go for JavaScript to open up a printable certificate, but somehow the variables don't seem to get passed on to the certificate when using Internet Explorer (Firefox works fine though). Does anyone know how to fix this?
This is the JavaScript run in Storyline when the user clicks a "Print" hotspot:
var newWin=parent.window.open("report.html", "Kursintyg");
And this is the JavaScript that goes in the certificate (report.html):
var player=window.opener.GetPlayer();
var fornamn=player.GetVar("Förnamn").replace(/(\r\n|\r|\n)/g, '');
var efternamn=player.GetVar("Efternamn").replace(/(\r\n|\r|\n)/g, '');
document.write(""+fornamn+" "+efternamn+"");
I would be very grateful for help, as I've struggled a long time with this. Thank you. :)
3 Replies
Hi, Andreas -
I just wanted to share that although we don't provide support for JavaScript coding, it may be helpful to take a look at this document on JavaScript Best Practices. Hopefully, some of our JS experts in the community can chime in with suggestions!
Hi Christine,
I am aware Articulate does not provide JavaScript support, but as printable certificates are something many users are likely to request I hoped the community had long since found a good general solution.
In any case, I solved it by modifying this script, which uses JavaScript to send the user variables to the certificate using POST (creating a temporary form). The variables are then read from the certificate using PHP.
The JavaScript run in Storyline when the user clicks the "Print" hotspot:
The JavaScript that goes in the certificate (report.php):
HI, Andreas - Thank you for the update and for sharing your discovery! :)
This discussion is closed. You can start a new discussion or contact Articulate Support.