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

  mattyc_92 14:53 21 Mar 05
Locked

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 "javascript:window.open(click 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 05

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

  mattyc_92 18:00 21 Mar 05

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>
</SELECT></p>


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 05

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

Soz about that....

  smudge101 22:27 21 Mar 05

<html>
<head>
<title>Select Link</title>


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


</head>
<body>
<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>
</select>

</div>
</form>

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

  smudge101 22:29 21 Mar 05

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 05

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

Thanks again...

  mattyc_92 10:56 22 Mar 05

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 05

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 05

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 05

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.

How to get Windows 10 for free | How to install Windows 10: There is still a way to avoid paying…

1995-2015: How technology has changed the world in 20 years

Alex Chinneck’s giant ice cube Christmas tree at Kings Cross

Apple rumours & predictions 2017: The iPhone 8, new iPads, and everything else you should expect fr7…