Close an open web object in new window.

Apr 06, 2018

I have built a calculator in storyline that I am opening in a web object in another course. So they can move it around the screen I am opening the web object as a new window. 

However if I open another instance of the calculator I get another new window calculator, and so on...

Is there a way to close the other calculators when the new one is created?


4 Replies
Matthew Bibby

Yes, this should be possible. 

Rather than using a web object, open your calculator using JavaScript so you can give it a handle:

calculatorWindow ='', '_blank', 'width=400,height=600');

Note that in the above code I'm deliberately not explicitly creating a variable. Storyline will wrap this code in a function which would mean the calculatorWindow variable wouldn't be accessible by our other script, but by leaving it undeclared it'll find it's way into the global scope.

I'm also setting the height and width as this will force a new window (rather than a tab) in most browsers.

Then you can close that window with a simple:


I haven't tested this, but it should work.

Also... and I'm sure you know this Phil... but you don't need to upload your calculator to a server to use this approach. Add it as a web object, publish, find it's identifier by looking in the story_content/WebObjects/ folder, then use that to create your link, e.g. story_content/WebObjects/7aG4BQzPAvH/story.html then drop that into the first block of code above:

calculatorWindow ='story_content/WebObjects/7aG4BQzPAvH/story.html', '_blank', 'width=300,height=200');

Let me know if this does the trick. Also, check how different browsers handle this to make sure the calculator is opening in a separate window in browsers that support such things.


fbs 419

"I haven't tested this, but it should work."  It doesn't.  Because there doesn't seem to be a good way to use a WebObject for a dynamic URL, I just do a window.Open without a _self, so the website will open in a new window.  I disable the button to open the window after I've opened it, so you can't open multiple windowa.  But I wanted to know when the other window was closed, so I could enable the button again.  So I put a close button in that does a window.close and execute some javascript to close the window.  But it doesn't work.  It doesn't work with undeclared window handles, and it doesn't work with Articulate variables, although I don't know why it should because there is no Articulate variable type for a window handle.  Number doesn't work.  So it seems there is no way to close a window opened this way.  At least not via a different button.

This discussion is closed. You can start a new discussion or contact Articulate Support.