Close an open web object in new window.

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?


3 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.