Forum Discussion
Print button - javascript
Hi, I would like to add a button that would allow the user to print the page. It seems like the easiest way would be to add a trigger to a button to execute javascript. Unfortunately, I know nothing of javascript. Can someone help me out with what need to goes into that script box?
Thank you!!
- SteveFlowersCommunity Member
To the question about not printing the "print me" button, you might try adding a trigger to hide the print button before calling the JavaScript to print the page.
To the question about printing to landscape orientation - unfortunately, the browser interface through JavaScript doesn't offer any controls of the print dialog options. You can ask the browser to print the page but that's about it. There are some tricks you can run if you have some Flash authoring / ActionScript skills and access to Flash but short of that you're stuck either 1) asking the user to change the print settings to landscape or 2) living with the portrait default.
- YeonhaKwak1Community Member
Can you tell me the detail about the trigger hiding print me button?
Thanks.
Hi Jenny! Just in case Steve is no longer subscribed to this thread, feel free to use the Contact Me button on his profile page to reach out and reference his comment!
- FelixFrankeCommunity Member
"To the question about not printing the "print me" button, you might try adding a trigger to hide the print button before calling the JavaScript to print the page. "
Haha, that made me laugh, it's so simple. Just tried it out, it actually works. Thank you! The order of the triggers is essential though, as described.
Sorry old thread but this so ingeniously simple I had to leave my kudos.
- BrettRockwoodCommunity Member
I too know next to nothing about javascript but I believe if you add the following as a your script it will print the current window:
window.print();
At least is worked for me once...
- MarkRamsey-7e11Community Member
I don't know whether this assist others in this thread, but I came up with an alternate solution. It's a bit more involved on the Javascript side. I create an entire new HTML page using Javascript that you can brand and form anyway you like, then use the browser controls to print. It is more involved, and you would probably need a good HTML lay-out person to get your branding/layout correct, but it works in all browsers and evidently is not even cached, just placed in temp memory. Here's the link:
- NancyWoinoskiSuper Hero
Yes that should do it.
So Alex, you can create a button in Storyline and then add a trigger using the JavaScript Action.
Click the ... button beside the work Script and add the code there.
You have to publish your coure to see it working. JavaScript does not work in Preview mode.
- DianeBoeweCommunity Member
I just used the JavaScript Action and it worked for me! Thank you so much for sharing this information!
- JimHandysideCommunity Member
Tested the print script in IE - works fine.
Fails in Chrome - java-related browser issue?
- NancyWoinoskiSuper Hero
Hi Jim, I think it is a browser security issue. Where you testing locally or over the internet?
Chrome blocks javascript when running locally.
- NancyWoinoskiSuper Hero
This might be a stupid question, but do you have JavaScript enabled in the Firefox options?
- PhilMayorSuper Hero
Ivana Pavcic said:
Hello there,
I was wondering if anyone in the community could help me.. I have used the javascript desribed in this post to print a certificate that will be unfortuntely printed out with the player. I would like to include a line in the javascript that says "remove the print button before printing". Condering that I know aboslutely nothing regarding java, and my google searches have turned up nothing, does anyone know the actual programming language I can include with the window.print(); command that will do this?
Thanks,
Ivana
As Steve says just add a trigger to hide th print button, ensure the trigger is above the javascript trigger - JillMcNairCommunity Member
Anyone know of a way to allow learners to print a multipage document? My client wants learners to be able to print a six page document (a job aid). It is a PDF. I thought perhaps learners could just download the PDF, then prinit it themselves, but the client says that their LMS will not permit that. Seems unusual to me. Any suggestions would be appreciated.