Skip to main content
September 30, 2008
Answered

Open URL; constraining window that opens

  • September 30, 2008
  • 5 replies
  • 1579 views
Here is my challenge: I want to link to another project and have that project open in a new window. Is there a way within Captivate 3 that allows me to constrain those features in the new window that is going to open?

In non-Captivate instances, when I want to constrain in this way, I can embed these characteristics in the launch button by using Dreamweaver when creating my launch button in the launching html. I don't see a similar opportunity when setting button properties in Captivate. Any ideas?
    This topic has been closed for replies.
    Correct answer jbradley88
    By any chance is your Captivate button context set to "New" (via the little down arrow button to the right of the Javascript field)? That would explain what you're seeing.

    The context for the button containing the openNewWin() call should be set to "Current", since the Javascript code needs to execute in the current window where standard.js is loaded.

    Otherwise, it works fine when I copy/paste the code above into a freshly-published standard.js.

    5 replies

    jbradley88Correct answer
    Participating Frequently
    October 15, 2008
    By any chance is your Captivate button context set to "New" (via the little down arrow button to the right of the Javascript field)? That would explain what you're seeing.

    The context for the button containing the openNewWin() call should be set to "Current", since the Javascript code needs to execute in the current window where standard.js is loaded.

    Otherwise, it works fine when I copy/paste the code above into a freshly-published standard.js.
    October 22, 2008
    Hooray, JBradley88!! That simple switch from New to Current (window) is the answer! Thank you so much for your help.
    Participating Frequently
    October 2, 2008
    Bravo, Rick! You bring up a very good point.

    I only test from a web server, so I never see the Flash Player security warning when viewing published files.

    I just tried it from my local machine and got the warning, which means that Javascript is being blocked from executing, among other things.

    Captivate's built-in window opening code doesn't rely on Javascript, so I wouldn't be surprised if that worked while the Javascript-based approach failed.

    Best regards,
    John
    October 3, 2008
    Hi, Rick.
    I tried it, but I'm sorry to report that it did not help. What it did do is eliminate having to see the Flash security warning when I click on one of the buttons that is set to "open other project," so in that respect I know it had an effect.

    But still, I cannot open a new window using the "Execute JavaScript" command. I think I must be doing something wrong in the JS I am inserting into the 'standard.js' file. I am going to attach the code I am trying, and maybe something will stand out for someone.
    October 7, 2008
    Hi again,
    I'm still trying to get this to work, without success so far. However, there is a change in what I see, now that I have changed my security settings, per Rick's advice. Now, when I click on the button, I get a very brief flash of what looks like the new window I want. It flashes on and off so fast, you cannot see what, if any, content is contained there. This is definitely different from what I saw in my initial post.

    Does this ring a bell or sound familiar to anyone?? Thanks for helping.
    Participating Frequently
    October 2, 2008
    As to the question of window style, that is defined in standard.js in the line

    strParams="width=790, height=545";

    I didn't want to add too many default parameters since some can have undesired consequences depending on what you're trying to accomplish.

    That said, a full example of the values you can use in strParams is shown below. Unless you're explicitly interested in setting a particular value, you should remove the reference (especially the left= and top= values, since those hardcode the window to appear at a specific location on the screen):

    strParams="width=790, height=545, left=0, top=0, location=no, directories=no, channelmode=no, fullscreen=no, menubar=no, resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=no";

    MSDN has a description of the parameters for the window.open() method, including the differences between these parameters in IE7 and in earlier versions of IE. It was the first link when I Googled the phrase 'window.open parameters'.
    October 1, 2008
    Thank you! This sounds like just the ticket. I will try it.
    October 1, 2008
    I cannot seem to make this work, but I am sure that is due to my lack of technical skill, not the solution itself.

    I followed your directions literally, and cut and pasted into the standard.js, which now reads just like this:

    //Copyright 2006 Adobe Systems, Inc. All rights reserved.
    //
    //This is the base class for implementing an Active Content extension -- a piece of code that knows how to rewrite OBJECT tags so that they comply to the Eolas patent without making the browser display the "Press OK to continue loading the content of this page" message box.
    //
    // When the user hovers the mouse over an ActiveX control in Internet Explorer 6 updated with (April 2006) Cumulative Security Update (912812) or Internet Explorer 7, the following message is displayed:
    // “Press Spacebar or Enter to activate and use this control.”
    // The user can now click the mouse anywhere inside the ActiveX control area, or press the Spacebar or Enter key to activate the control.
    // The standard.js file has been introduced to retain the earlier behavior where the control remains interactive from the first click to the last.

    function writeDocument(s){document.write(s);}

    function openNewWin(strFile,strWinName,strParams)
    {
    if (!strFile)
    alert("No file specified in openNewWin!");

    if (!strWinName)
    strWinName = "newCPTWin";

    if (!strParams)
    strParams = "width=790, height=545";

    var o = window.open(strFile, strWinName, strParams);
    o.focus(); // bring window to front if it's already open
    }

    Do I need to be replacing the values in the parentheses with the actual filename of the other project I wish to call? (the .htm file, no doubt?)

    And, do I need to create my window style and give it the name of "newCPTWin"?

    Any advice will be greatly appreciated. Thanks!
    Participating Frequently
    October 2, 2008
    On first glance, the code looks good, although I may have introduced a typo that I'm just not seeing. What error/problem are you seeing?

    Note that you do need to republish your project at least once for the modified code to make it to the directory holding your published content.

    Did you remember to insert the function call into Captivate that actually triggers the code you added to standard.js? That's also where you need to specify the exact file name you want to open.

    It's this part from the original post above:

    Then, in your Captivate file, use the following in the Execute Javascript field:

    openNewWin('filename');


    You'll probably want to add the function call to the On success action of a Captivate button, but you can add it to pretty much any interaction, and even a slide if you want the new file to open automatically when the user leaves the slide.

    Just remember to replace 'filename' with the full name of the file you want to open in the new window, such as:

    openNewWin('myfile.htm');

    or

    openNewWin('mydocument.pdf');
    Participating Frequently
    September 30, 2008
    Assuming you're publishing to HTM/SWF format, you can do what you want via Javascript using the window.open() method. In the button/click box properties, select an On success Action of "Execute Javascript" and then click the Ellipses (...) button to add your custom Javascript code.

    If you plan on opening a new window with the same properties more than once in a project or across multiple projects, add the window opening code to the standard.js file in the Templates\Publish folder in the Captivate install directory.

    The standard.js file is automatically included whenever you publish a project, which allows you to centrally control the code in case you want to make changes.

    Here's an example from an old post: