0
How to Use JavaScript to Open a New Window?

/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/td-p/250787
Jul 16, 2007
Jul 16, 2007
Copy link to clipboard
Copied
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
Kind regards,
CapManZ
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250788#M11859
Jan 04, 2008
Jan 04, 2008
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advocate
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250789#M11860
Jan 04, 2008
Jan 04, 2008
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250790#M11861
Jan 09, 2008
Jan 09, 2008
Copy link to clipboard
Copied
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advocate
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250791#M11862
Jan 09, 2008
Jan 09, 2008
Copy link to clipboard
Copied
Try the following code. It should do the trick.

Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250793#M11864
Mar 12, 2008
Mar 12, 2008
Copy link to clipboard
Copied
From my further reading -- do I understand correctly that I
need to have my files on a webserver to see the Javascript
functionality?
I'm working from home and unable (right now) to load on a server. I'd really like to be able to preview this -- but, seems I won't be able to until I'm back at work.
I'm working from home and unable (right now) to load on a server. I'd really like to be able to preview this -- but, seems I won't be able to until I'm back at work.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250794#M11865
Mar 12, 2008
Mar 12, 2008
Copy link to clipboard
Copied
Hi Joe,
At the moment, I am working on the very same thing. What I do to test is to make a folder on the root of my C: Drive and map everything to that folder. That way you can be sure everything will work when you finally set the paths to their location on your server.
However, I'm fairly new to this, so I'm sure there is an easier way:)
At the moment, I am working on the very same thing. What I do to test is to make a folder on the root of my C: Drive and map everything to that folder. That way you can be sure everything will work when you finally set the paths to their location on your server.
However, I'm fairly new to this, so I'm sure there is an easier way:)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250796#M11867
Mar 12, 2008
Mar 12, 2008
Copy link to clipboard
Copied
> From my further reading -- do I understand correctly
that I need to have
> my
> files on a webserver to see the Javascript functionality?
>
Yes.
Steve
> my
> files on a webserver to see the Javascript functionality?
>
Yes.
Steve
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250792#M11863
Mar 11, 2008
Mar 11, 2008
Copy link to clipboard
Copied
Hi jbradley88:
Just a quick note to tell you that this solution works beautifully. Thank you very much!
Dogjay
Just a quick note to tell you that this solution works beautifully. Thank you very much!
Dogjay
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250795#M11866
Mar 12, 2008
Mar 12, 2008
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250797#M11868
Mar 12, 2008
Mar 12, 2008
Copy link to clipboard
Copied
okey-doke. Thanks.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250798#M11869
Mar 13, 2008
Mar 13, 2008
Copy link to clipboard
Copied
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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250799#M11870
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/captivate-discussions/how-to-use-javascript-to-open-a-new-window/m-p/250800#M11871
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
But the standard.js method is better for those who are not
restricted by administrators from editing this file!

Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

