Forum Discussion
Closing module mechanism
Is there a way to do the following:
If a user closes the module at any time using the "X" of the window --> redirect to another URL.
Also I have a jscript inside my storyline that stores the userID, is there a way to have that as a parameter in that URL that I am redirecting?
- SamHillSuper Hero
Hi RonLinder-4c1a3 if you are saying the "x" on the browser window, I don't think you can then stop that action and re-direct to another URL. If you are suggesting that they close "x" on browser Window 1, which then re-directs browser window 2, this should be possible using JavaScript "onbeforeunload" event listener in Window 1.
Note: Window 2 would also need to be controlled by Window 1 in this instance (for example launched by it), in order for it to allow any script in Window 2 to affect it.
It would also be possible to get the userID and use it as a parameter in the URL:
const player = GetPlayer(); const userID = player.GetVar("userID"); const url = `https://abc.com.au?userID=${userID}`; // You'd need to adjust this for the browser window you are targeting document.location = url;