Skip to main content
July 16, 2007
Question

How to Use JavaScript to Open a New Window?

  • July 16, 2007
  • 7 replies
  • 2812 views
I've been trying to get a new window to open (that will "sit on top of" the Captivate movie's html page) after the User clicks on a clickbox. I've read through many, if not most, of the posts concerning the use of JavaScript with Captivate & have tried several of the solutions, but all to no avail. Can someone possibly please outline the steps that have worked for him/her in order to get this to work? I would certainly appreciate your help!

Kind regards,
CapManZ

    This topic has been closed for replies.

    7 replies

    April 21, 2008
    But the standard.js method is better for those who are not restricted by administrators from editing this file!
    April 21, 2008
    Another way to do this in Captivate 3, to open new window using javascript with multiple files:

    Create button and choose Execute Javascript:

    Click the "..." button and type command using the following format:

    JavaScript:mynameLaunch();

    ["myname" is the name of the javascript function in relation to the file you want to open]

    Publish the Cp file.

    Copy the file to be opened over to the root of the htm file folder (for this example "myname.pdf").

    Place the below javascript in the head of the main htm file after publishing.

    <head>

    <script src="standard.js" type="text/javascript"></script>

    <script type="text/javascript">
    function mynameLaunch(){window.open("myname.pdf", "","toolbar=no,location=1,top=50,left=50,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=575");
    }
    </script>

    </head>

    Test on a web server.
    Inspiring
    March 13, 2008
    Update: We installed IIS on my laptop today. I published my files to my new local default site and ran 'em from there.

    This, of course, turned my laptop into a web server.

    Worked great! All the functionality worked and I don't have to load to a separate box to test.

    Telecommuting rules!!!

    Joe
    Inspiring
    March 12, 2008
    okey-doke. Thanks.
    Inspiring
    March 12, 2008
    Understood. What I'm trying to do is to be able to launch an external html file with links to various reference documents for my project so that my users will be able to review the docs at their leisure.

    I can't get the external file to launch. When I click on my button to execute javascript to open a browser window, nothing happens.
    Participant
    March 11, 2008
    Hi jbradley88:

    Just a quick note to tell you that this solution works beautifully. Thank you very much!

    Dogjay
    Participant
    January 4, 2008
    I need the answer to this question too. I was having difficulty doing this in Captivate 2 and I am still having the same problem in Captivate 3. Here is the Javascript I am using:

    javascript: window.open('flyingWords.htm','FlyingWordsGame','left=0, top=0, width=700, height=520, titlebar=no, menubar=no, toolbar=no, location=no, directories=no, resizable=yes, scrollbars=yes, status=no');

    In the Click Box Properties, in the On success Execute JavaScript field drop-down (Select destination window and other options) I select New.

    Results: When published to HTML and run in the IE browser, and the click box is clicked, the new window flashes on screen then immediately closes. I can't get the new window to display for more than a split second and run my FlyingWordsGame.swf. FYI: It's not the pop-up blocker. I always override the pop-up blocker with my Ctrl key.
    Participating Frequently
    January 4, 2008
    Some users have reported better luck moving the actual code out to the standard.js file that is published with every file and then inserting only a function call in Captivate.

    NOTE: When adding code to standard.js, add it to the version in the Publish subdirectory of the install folder for Captivate. This is the file that Captivate copies to your Publish directory every time you publish a project.

    So, using the example provided by Dogjay, you'd add your code as shown at the bottom of this post. The use of var o and focus() in the code forces the new window to always pop to the front.

    I would recommend against specifying "New" in Captivate since you're essentially specifying that Captivate try to open a new window that will then open another new window. I wouldn't expect that to work, but if it did, you'd have an extra blank window for no reason.
    Participant
    January 9, 2008
    Thanks for your help jbradley88. However, it looks like altering the standard.js per your instructions will allow me to launch only one .swf. I have several .swfs that I need to launch in a new window from the same course. How can I play the other .swfs if the standard.js is hardcoded with with only one .swf title? I apologize for my lack of knowledge (I am not a programmer). Again, I'm appreciative of any help you can give to me.