Opening a link in a new window (from a drop-list)

  mattyc_92 14:53 21 Mar 2005

Hi.... I have created a "drop-list" menu and I have got ALL the links working, but would like to know "how can you open one of the links in a new window?"

I have tried " here)" but it then just doesn't open the link at all...

Can someone please help??

As normal, thanks in advanced....

  smudge101 17:56 21 Mar 2005

Could you please post the relevent part of your code and I will have a look.

  mattyc_92 18:00 21 Mar 2005

Ok.... it is as follows....

<SELECT ONCHANGE="window.location.href = this.options[selectedIndex].value; this.selectedIndex=0" name="drop_list" size="1">
<OPTION STYLE="color: navy" SELECTED>Please select a search engine...</OPTION>
<OPTION VALUE="click here" target="_blank">All The Web</OPTION>
<OPTION VALUE="click here" target="top">Google</OPTION>
<OPTION VALUE="click here" target="top">Yahoo</OPTION>

I want to make ALL three (All The Web, Google and Yahoo) to be opened in a new window, thus leaving my site open in the background (if this is possible)...

  mattyc_92 18:01 21 Mar 2005

the "target="_blank"" doesn't do anything, and I forgot to change it back to "top"....

Soz about that....

  smudge101 22:27 21 Mar 2005

<title>Select Link</title>

<script language="JavaScript">
function NewWin(form) {
var url=(form.dir.options[form.dir.selectedIndex].value);
myWindow =, 'myWindow', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes,width=500,height=400');
// -->

<form name="DroplistForm">
<div align="left">

<select name="dir" size="1" onchange ="NewWin(this.form);">

<option value="">Choose a Site</option>
<option value="click here">All The Web</option>
<option value="click here">Google</option>
<option value="click here">Yahoo!</option>


The main thing to not from your previous code is that all values in the options should be unique.

  smudge101 22:29 21 Mar 2005

It is getting late and the old brain has switched off, disregard my last comment.

I hope you find the code does what you want :0)

  mattyc_92 09:27 22 Mar 2005

thanks... I will try it later when I have time...

Thanks again...

  mattyc_92 10:56 22 Mar 2005

I have tried it, but it doesn't do anything at all now... When I select an option, it doesn't display the link in the window or make another....

Also, I would like to point out that this drop-list doesn't use a submit button e.g. when you select the option it goes straight to the site I have selected

Am I doing something wrong???

  smudge101 12:30 22 Mar 2005

It works for me.

I have put it on my site click here

Give it a go you can right click & 'view scource', you can cut n paste it from there.

The link works as soon as you select from the list (no submit button), Make sure you do not have a pop up blocker active as it may stop the new window from showing.

  mattyc_92 12:40 22 Mar 2005

What part(s) do I need for the drop-list???... I am guessing it this from <script language="JavaScript"> to the <Body> tab??? or do I need the script between <body></body>???

  mattyc_92 12:46 22 Mar 2005

Ok.... worked out what part of the script I need and it works.... I think it was because the script you posted here, didn'y have the line-spaces like you have to have on the html script....

Thanks for your help....

Going to tick this thread now...

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

iMac Pro review

Illustrator Charles Williams on how to create magazines and book covers

iMac Pro review

Les meilleures prises CPL (2018)