Forum Discussion
Help With JavaScript code for Text Entry Printing in Storyline 360
Is anyone who is experienced in JavaScript willing to look at my code and tell me if you see anything wrong with it?
I'm trying to pull multiple text entry answers so the learner can print them all at the end of the course. It's code I've pulled from another course that works perfectly in that course, but somehow is not working in this new one.
I'm testing it in Review 360 and on Chrome. Those are the same conditions that I'm able to get the other course to work in, so I assume those aren't the issue.
When I click the button, nothing is launching or triggering at all. I'm using Visual Studio Code to write it and then copying and pasting into the execute javascript trigger in Storyline.
I've attached a sample of the project here, which is the last few slides and the print button. Any help anyone could offer would be so appreciated!!
- StacySpringer-6Community Member
- TeresaVanderposCommunity Member
Just to pipe in jshint.com helped me alot when as a non-coder I was trying to print my text entry reflection notes from multiple slides and I was successful in the end.
- PhilMayorSuper Hero
I haven't looked any further than from line 54 you have not closed the paragraph string for most of the subsequent lines.
- MathNotermans-9Community Member
Exactly as Phil states. Here you see your code in SublimeText. I am wondering... if you made your code in Visual Studio Code.... do these errors not show there ?
All the red blocks are lines not closed properly. - AshleyBurge-83cCommunity Member
Thank you so much for your help Phil and Math! I should have mentioned I'm a total novice with coding but trying to learn. From what I can see in Visual Code Studio, it's not highlighting those lines, but I could be looking at it wrong.
Can I ask how I might close them properly?
- PhilMayorSuper Hero
Hi Ashley just add a " at the end of each para end before the ;
- AshleyBurge-83cCommunity Member
Thank you! I've applied the closing " to each line, and tested again, but still not getting anything to launch. I've attached the updated version. Any other ideas? Could it be a Storyline version issue maybe?
- MathNotermans-9Community Member
When working with Javascript the developers tools in the browser are your best friend...
here you see them in action and finding an error on line 82
- MathNotermans-9Community Member
Finxing that by changing the "bad guy" to 'bad guy' and it works... well partially...
As you can see, the window opens but a lot of the info in it is 'null'
As you can see the text input field works though.. i filled 'Jabbadabba doe' in...;-) Thats the only variable in your sample..so it basically works...
- AshleyBurge-83cCommunity Member
You have saved the day!! Or my day rather. Thank you so very much.
It's amazing how something that small can cause issues. I've look in developer tools, but reading it sometimes feels like a foreign language, so the learning journey continues!
The print button itself, in the launched window, doesn't work, but that's okay because they can still click Ctrl+P and that will trigger it. And for now, that will have to do! Thank you!!!!
- MathNotermans-9Community Member
Javascript is really picky on spelling... thats why its best to use a editor like Brackets, Visual Studio or Sublime Text. Debugging in the console/developers tools indeed will take some practice.
- StacySpringer-6Community Member
I have the same issue. Even if I replace my code with a simple JavaScript command such as
window.print();
Storyline 360 will still not execute the JavaScript code tied to a button (Execute JavaScript When the user clicks Btn_Print).- PhilMayorSuper Hero
There is a print screen trigger now. But that should work. Have you looked at the console to see what error you are getting? I suspect you have bad syntax in some javascript in the course somewhere.
Sent from my iPhone
- StacySpringer-6Community Member
Hi Phil, I am trying to print variable responses to PDF. This has worked in the past (March 2022). I have been testing the published version on my Review 260 with Firefox's web dev tools. Here are the errors I get:
Still tracking the issue with Firefox developer tools: Here are the errors when the button is pressed:
actionator::exeJavaScript - this.execUserJs is not a function bootstrapper.min.js:2:149273
Referrer Policy: Ignoring the less restricted referrer policy “no-referrer-when-downgrade” for the cross-site request: https://n.clarity.ms/collect 840.39dbb679ee07e8aa.js:1:37488I have attached my Javascript. Also, I still get the same thing when my Javascript is just Window.print();
The previous media piece that uses the same script still works (Published in March 2022) is here: https://360.articulate.com/review/content/8f330d28-988d-40fa-acee-106a09d76f4a/review
This issue has been resolved! If you have problems with your JavaScript, here are the troubleshooting steps that helped me (compiled from things found on the web):
1. Take the JavaScript and button and copy them into a blank Storyline file. Publish and test. In my case, the button worked.
2. Look at any JavaScript in the Storyline file that may have errors.
3. Use the Web Dev tools in your browser to identify errors.
4. Check your Slide Masters for any issues.
5. Don't edit your code in Microsoft Word. There is a difference in quotation marks that can cause an issue.
6. Check that your browser is not blocking JavaScript.
7. Change your JavaScript file to show just one command such as print.window();
8. Don't be afraid to ask for help, another set of eyes is really helpful!
My problem was that I had a hidden slide out there where I was working through sliders and dials, specifically retrieving and setting the variables. The issue was there. Once I deleted that slide, my JavaScript button started working. Hopefully, this helps others.