Execute Javascript Question

Get help using Construct 2

Post » Sat Oct 05, 2013 3:22 pm

With (what I am sure are well-founded) warnings about using Execute Javascript in Construct 2, I'm hoping that someone can provide me with either assurances or further warnings regarding the following instance of Execute Javascript:

   Execute javascript "javascript:window.print();"

Do you think this is something that could cause security issues, etc... ? If so, have you found any alternate ways to achieve a window print?

FYI, I'm not just asking off the top of my head. I tried to be a responsible community member by searching the manual, tutorials and forums but failed to find a solution.
B
18
S
3
G
2
Posts: 28
Reputation: 2,684

Post » Sat Oct 05, 2013 3:28 pm

You don't need the "javascript:" part at the front. Your game will also crash on non-browser platforms like CocoonJS that don't provide a window.print function, so you should check the function is there before you use it, as in: "if (window.print) window.print();"
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Sat Oct 05, 2013 4:05 pm

Thank you so much for your reply and tips @Ashley (and for correcting my javascript)

I'm going to be publishing this only for browsers for the time-being. My primary concern is to ensure there will be no security issues. Of course functionality is pretty darned important too ;)

This will be my first published project made with Construct 2, so... fingers crossed!
B
18
S
3
G
2
Posts: 28
Reputation: 2,684


Return to How do I....?

Who is online

Users browsing this forum: hrisnz and 8 guests