Javascript to open and close an external webpage

Hi, folks

I'm doing a little experiment for a friend and if it works, there's a blog post in it. I have got it up to a point, but it still scores a good 3 on a 1-5 clumsiness rate, and it would be great if it could be done much more smoothly.

I am trying to assign a few triggers to one button, an one of these triggers is to open a particular web address I have no control over - say - but also close it automatically after some time. There could be a few practical applications for this (from a test to see how much people pick up from a super quick scan on the most up-to-date resources). I don't want to have an easy life by storing copies of live pages locally or continuously cooking new exercises (and copyright also gets in the way)

So I was wondering if any JavaScript wizzes out there coudl help me out with the code that is needed to open an address, but also close it (if it's possible).

The following failed abysmally and I will just admit it that I am no programmer... :(

<script language="javascript">




Many thanks in advance,

Dragos :)

2 Replies
Dragos Ciobanu

Hi again, everyone

Going slowly mad, and could really appreciate some pointers. I'm having trouble triggering JavaScript from my Storyline buttons. A kind colleague has sorted me out with the JavaScript function I needed to make an external window pop up and then close by itself.

function openWin1() {


                var myVar = setTimeout(function(){closeWin()},4000);

                function closeWin()        {





As I did not manage for the life of me to make it work within the Storyline Javascript trigger which I could associate with a button, I'm storing the function in an external file and referencing the file in my published story.html using

before the closing tag. (I used the exact same method for this file and all seems to work fine)
Then, in Storyline, I was hoping that something like onclick="openWin1()"; in the Javascript trigger for a button would call up the function (as it does in the little HTML file above).
Looking at the user.js file, though, it seems that it's turning everything in the Storyline Javascript trigger box into a function of its own.
So, before I go totally crazy, is there a way to call up the openWin1 function by pressing a Storyline button?
Thanks a lot, folks :)
PS: to make things worse, I also associated other Javascript triggers with my button - stuff I borrowed from the best practises page , namely (without bullets). They don't work, either... man...
  • alert("Your message here..."); 
  • window.print();
  • var email="";
  • var subject="subject line";
  • var body_start="How you want to begin your body.";
  • var mailto_link='mailto:'+email+'?subject='+subject+'&body='+body_start;