Using JavaScript to change a web objects address -- need advanced help
May 19, 2015
I have five buttons that each open a lightbox slide with five different web addresses (in web objects).
What I want is to have ONE lightbox slide that opens a web object (with any URL) and then executes javascript when the timeline starts that will replace the URL in the lightbox. The button has a trigger that sets the variable "Test" to the new URL.
Here is a sample of the code I've tried:
var player = GetPlayer();
window.location.replace(player.GetVar("Test"));
Unfortunately, it doesn't work the way we want it to, it opens the new URL in the parent window, replacing Storyline. Not good... need it to open the URL in the lightbox web object, not the browser main window.
This way, I can have as many buttons as I want, without having a lightbox hard-coded for each button. My question: How do I replace the web address of the web object in the lightbox? Thank you all for your help! ACE
2 Replies
You might be able to have one web object that points to your own custom html file which would contain javascript that talks to the player to get the current value of the variable so that you can update the location of the web object.
Hi, Alan -
I see that Chad is assisting you here! I did want to pop in to mention 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 the JS experts in the community can chime in with additional suggestions! :)
This discussion is closed. You can start a new discussion or contact Articulate Support.