Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to Use JavaScript to Open a New Window?

Guest
Jul 16, 2007 Jul 16, 2007
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

2.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2008 Jan 04, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 04, 2008 Jan 04, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 09, 2008 Jan 09, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 09, 2008 Jan 09, 2008
Try the following code. It should do the trick.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 12, 2008 Mar 12, 2008
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 12, 2008 Mar 12, 2008
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:)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2008 Mar 12, 2008
> 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 11, 2008 Mar 11, 2008
Hi jbradley88:

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

Dogjay
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 12, 2008 Mar 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 12, 2008 Mar 12, 2008
okey-doke. Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 13, 2008 Mar 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 21, 2008 Apr 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 21, 2008 Apr 21, 2008
LATEST
But the standard.js method is better for those who are not restricted by administrators from editing this file!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources