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!!
69 Replies
- 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...
- 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!
- OmarWilkinsonCommunity Member
This in formation was great. I too know nothing aout Java scripts. I used the script and it printed the page. However, the button showed in the print. Is there away that I can put the button on another slide and enter a script to print a particular page or hide the button from printing?
- ErikaRomenesko1Community Member
Similar to Omar, I am looking for some code to take the text from the text entry (which is set to a variable (UserNotes) and print just that. Not the screen or any other buttons. Any suggestions or resources? Thanks!
- JesseSpinellaCommunity Member
Is there any more information on this topic anyone could link to or share? I'm also wondering about printable features within Java Script triggers.
- JesseSpinellaCommunity Member
Omar Wilkinson said:
This in formation was great. I too know nothing aout Java scripts. I used the script and it printed the page. However, the button showed in the print. Is there away that I can put the button on another slide and enter a script to print a particular page or hide the button from printing?
On page 1, I had the button link to a new slide with a trigger that says: Execute Javascript when the timeline starts. In the ... button I inputted the JavaScript print command. This avoids having to do anything funky with the Print Screen button. I ended up putting the variables and scoring page on a second slide that was 'printer friendly,' basically I created a new page with my own table.It'll print the page the moment the user clicks the Print button on page one.
- JesseSpinellaCommunity Member
Actually, correction, it printed the previous slide, not sure why. So, I just added a print button at the bottom of this page, simple fix. Doesn't get in the way of the table.
- CajiRCommunity Member
Thanks for the tip on window.print(); It worked for me. How can I get the window to automatically print in landscape orientation? What do I need to add to the JavaScript code?
- 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.