Opening a web links in a new window

  • 1
  • Question
  • Updated 3 years ago
  • Answered
This is the code I am using for a drop down menu. I would like to have all of the links in this code open in a new window. How can I do this?

<form> <select onChange="location=this.options[this.selectedIndex].value;"></script> <option value="">Select a Site</option> <option value="http://www.allaboutjazz.com/&quot;&gt... About Jazz</option> <option value="http://www.apple.com/&quot;&gt;Apple&...; <option value="http://www.appleinsider.com/&quot;&gt... Insider</option> <option value="http://www.applematters.com/&quot;&gt... Matters</option> <option value="http://www.nfo.net/&quot;&gt;Big Band database</option> <option value="http://www.billieholidaysongs.com/&qu... Holiday1</option> <option value="http://www.billieholiday.be/&quot;&gt... Holiday2</option> <option value="http://www.ottawacarsija.com/&quot;&g... Radio</option> <option value="http://www.ibdb.com/&quot;&gt;Broadway database</option> <option value="http://www.chuo.fm&quot;&gt;CHUO-FM&l...; <option value="http://www.classicmoviemusicals.com&q... Movie Musicals</option> <option value="http://www.downbeat.com&quot;&gt;Down... Magazine</option> <option value="http://www.drummerworld.com&quot;&gt;...; <option value="http://www.harlem.org/&quot;&gt;Great Day In Harlem</option> <option value="http://www.inamellowtone.blogspot.com... A Mellow Tone</option> <option value="http://www.jazz.com/&quot;&gt;Jazz&lt...; <option value="http://www.jazzateria.com/&quot;&gt;J...; <option value="http://www.jazzitude.com/index.htm&qu...; <option value="http://www.jazzconnectionmag.com&quot... Connection</option> <option value="http://www.jazzcorner.com/&quot;&gt;Jazz Corner</option> <option value="http://www.jazzdisco.org/&quot;&gt;Jazz Discography</option> <option value="http:/www.jazzreview.com/&quot;&gt;Jazz Review</option> <option value="http://www.jazzstandards.com/&quot;&g... Standards</option> <option value="http://www.usingmac.com/&quot;&gt;Mac Fun</option> <option value="http://www.mac360.com&quot;&gt;Mac 360</option> <option value="http://www.osxhelp.com/&quot;&gt;Mac OS X Help</option> <option value="http://www.maccentral.com&quot;&gt;Ma...; <option value="http://www.jazzmontreal.com/&quot;&gt... Jazz</option> <option value="http://www.nicolejo.de/&quot;&gt;Nicole Jo</option> <option value="http://www.the1920snetwork.com/index.... ">1920's Radio</option> <option value="http://www.musicweb-international.com... Music</option> <option value="http://www.realmacsoftware.com/&quot;...; <option value="http://www.redhotjazz.com/&quot;&gt;Red Hot Jazz</option> <option value="http://www.myspace.com/robertomagrisj... Magris</option> <option value="http://www.karelia.com/&quot;&gt;Sand...; <option value="http://www.sidneybechet.org/&quot;&gt... Bechet</option> <option value="http://www.parabrisas.com/index.php&q...; Big Band database</option> <option value="http://www.songwritershalloffame.org/... Hall Of Fame</option> <option value="http://www.swingmusic.net/&quot;&gt;S...; <option value="http://www.touchemusic.se/&quot;&gt;T... Music</option> <option value="http:/www.versiontracker.com/&quot;&gt;Vers...; </select> </form>
Photo of Randy

Randy

  • 643 Posts
  • 8 Reply Likes
  • looking forward to an answer.

Posted 9 years ago

  • 1
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
<!--
Hi Randy,

You could try and add this to the top of the page.

<base target="_blank">

It will make all the links on the page open in a new tab/window.

Or you could go through all the links in the menu and add target="_blank" after each href url.

Lee. -->
Photo of Randy

Randy

  • 643 Posts
  • 8 Reply Likes
Thanks Lee but will that work with the links I have in the pull down menu on my Home page or is there something else I have to do?
Photo of Randy

Randy

  • 643 Posts
  • 8 Reply Likes
<form>
<base target="_blank">
<select onChange="location=this.options[this.selectedIndex].value;"></script>
<option value="">Select a Site</option>
<option value="http://www.allaboutjazz.com/&quot;&gt... About Jazz</option>
<option value="http://www.apple.com/&quot;&gt;Apple&...;
<option value="http://www.appleinsider.com/&quot;&gt... Insider</option>

</select>
</form>
Photo of UK Duke

UK Duke, Champion

  • 3321 Posts
  • 213 Reply Likes
try and add it at the top of the page not inside the form.

If it does not work its becasue the links are controlled in some kind of javascript... You could add a snippt of code to the java script.but i wouldnt know anything about that. Javascript may as well be written in Chinese for me.

lee.
Photo of smithy

smithy

  • 1222 Posts
  • 28 Reply Likes
UK duke i know some about java script but not a lot. i know how to get the print page to load up with the page and some thiger stuff!! i got it some java scripts from this site www.quackit.com
Photo of smithy

smithy

  • 1222 Posts
  • 28 Reply Likes
<!--
the way to get it to open in another window is like this <a href="URL HERE" target="_blank">TEXT HERE</a>

-->

i hope this helps!!
Photo of Randy

Randy

  • 643 Posts
  • 8 Reply Likes
Thanks for the suggestions.

Smithy,

I tried what you mentioned but it doesn't work. Because I have a pull down menu, the code looks like this:

<option value="http://www.jazz.com/&quot;&gt;Jazz&lt...;
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hi Randy

Try replacing this line of code:
<select onChange="location=this.options[this.selectedIndex].value;"></script>

with this:
<select onChange="window.open(this.options[this.selectedIndex].value,'_blank')"</script>

Hopefully that will do the trick! Please let me know if it doesn't.
Photo of Emily Yutzy

Emily Yutzy

  • 1 Post
  • 0 Reply Likes
Thank you!
Photo of Randy

Randy

  • 643 Posts
  • 8 Reply Likes
Thanks Sanja,

That worked great!!

Now, how can I change the width of the drop down menus on my home page so that they are the same?
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
Hi Randy

You'll need to add a width dimension to your code. It will look like this:

<select onChange="window.open(this.options[this.selectedIndex].value,'_blank')" style="width: 200px;"</script>
Photo of Randy

Randy

  • 643 Posts
  • 8 Reply Likes
Thanks Sanja!! Works great. What do you think about me putting two pull down menus down the right hand side of my Home page? Do you think it look OK and is pretty easy for visitors?

Is there a better way to present my interviews? I had them on a separate page and then decided to move them to a pull down menu instead thinking it would make more sense for visitors because they are quick to access.
Photo of prum seng

prum seng

  • 1 Post
  • 0 Reply Likes
Yes, work like this:
<select onChange="window.open(this.options[this.selectedIndex].value,'_blank')"

Thanks for sharing your knowledge. 
Photo of Sanja

Sanja, Official Rep

  • 10698 Posts
  • 495 Reply Likes
I'm glad to hear that the code helped!

I think the two pull-down menus will work well. :) Yes.. I think using this idea to incorporate your interviews is a good one.
Photo of Donald

Donald

  • 2991 Posts
  • 37 Reply Likes
what website creator did you use to build that website?