homepage Welcome to WebmasterWorld Guest from 54.167.185.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
jumpPage query
How do I open new window in selection box?
Bran




msg:587558
 9:31 am on Aug 12, 2002 (gmt 0)

I am using a jumpPage script (in a selection box)to jump to a new url without clicking on "Go" but it always opens in the same window.

How do I get it to open in a new window?

The script is:
<!-- Hide script from older browsers
function jumpPage(newLoc) {
newPage = newLoc.options[newLoc.selectedIndex].value
if (newPage != "") {
window.location.href = newPage
}
}
// End hiding script from older browsers -->

And it is activated in a form as follows :

<form action="gotoLocation.cgi" method="GET" target="_blank">
<select name="newLocation" onChange="jumpPage(this.form.newLocation)" class="smalltext">
<option value="" selected>Option 1 etc

Any assistance much appreciated.

 

DrDoc




msg:587559
 6:29 am on Aug 13, 2002 (gmt 0)

Change window.location.href to blah.location.href

blah is the name of the window. If a window with that name doesn't exist it will be created. If you need to open a window with certain attributes, use the window.open method.

Bran




msg:587560
 8:43 am on Aug 13, 2002 (gmt 0)

Thanks for the reply DrDoc - I changed the script as suggested ......

But it is not working now - when I click on a new selection nothing happens.

Any thoughts?

transistor




msg:587561
 3:49 pm on Aug 13, 2002 (gmt 0)

Hey Bran,
A tip: when you have problems with JavaScript, try using Netscape or other web browser that can tell you where the error is. It makes debugging JavaScript much easier.

Now, what I would do is change the window.location.href = newPage for a window.open(url,name,attributes), or something very similar to that :)
That will guarantee a new window.
Hope that helps.

Bran




msg:587562
 5:38 pm on Aug 13, 2002 (gmt 0)

Sorry to be so dumb but I do not know how to use window.open in a drop down box or is it the jumpPage function that I need to amend to window.open?

Really new to this and only 2 strands of hair left!

transistor




msg:587563
 6:11 pm on Aug 13, 2002 (gmt 0)

Bran,
no problem, here:
In your function jumpPage, change line:
window.location.href = newPage
for:
window.open(newPage,'newWindow');
That's it! :)

Want to learn more JavaScript? I suggest you visit [javascriptsource.com ], they have lots and lots of JavaScripts for many different things, you can use and/or study the code.
Maybe the JavaScript reference guide would be useful too. I can't remember where did I downloaded it from, but if you like it I can send it to you by email, but notice, it is a 6.4 MB PDF file!
Let me know.
Cheers

Bran




msg:587564
 8:44 am on Aug 14, 2002 (gmt 0)

Many thanks, transistor - that is perfect!

If you could send me the file that would be much appreciated - fortunately I have broadband so the file size should be ok.

Thanks again....

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved