Forum Discussion
Closing module mechanism
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;
- RonLinder-4c1a36 hours agoCommunity Member
I managed to do it this way which is similar to your suggestion:
// Get the value of the Storyline variable let player = GetPlayer(); player.SetVar("Exit_Course",true); var empID = player.GetVar("student_id"); var url = "https://xxxx.com/index.aspx?csf=1&web=1&e=eDNr93&EmployeeID=" + empID; var win = window.open(url);
But the issue I am having is Workday does the following when someone navigates to a module:
- opens a tab in browser
- when you click to open the module it opens a popup window with the module in it
- how do I close that initial tab (in step 1) when the popup window is closed?
I tried:
var win window.top.close();
but nothing happens.
Also tried:
EXIT_BEHAVIOR = "ALWAYS_CLOSE_PARENT";
But no go as well.