Open new window in select drop down menu?

Does anyone know a good cross browser way of making a basic form select drop down menu with a new window opening when selecting a menu item? I would like to be able to resize the window and loose scroll bars , etc and also i want the drop down to be automatic - no GO button.

I know this is fairly basic… but i just can’t remember how to do this.

Cross Browser? Should be, try it :slight_smile: DEMO


<html>
<head>
<title>Pop URL on Select</title>
<script language="JavaScript" type="text/javascript">
<!--
function openPop(){
	var Sel_Ind = document.getElementById('myURLs').selectedIndex;
	var popUrl = document.getElementById('myURLs').options[Sel_Ind].value;
	winpops=window.open(popUrl,"","width=400,height=338,resizable,")
}
//-->
</script>
</head>
<body>
<select id="myURLs" onChange="javascript:openPop();">
<option value="">Select a page...</option>
<option value="http://news.bbc.co.uk">News</option>
<option value="http://www.the-company.com">Music</option>
<option value="http://www.b3ta.com">Laughs</option>
<option value="http://www.google.com">Search</option>
<option value="http://www.sitepoint.com/forums">Help</option>
</select>
</body>
</html>

Andy

Works a treat. Thanks Andy

Good stuff! Glad it works :slight_smile:

Off Topic:

Not sure why the SPF JavaScript forum now inserts underscores in the middle of javascript when inside code tags, but I’ve asked the question.

Andy

Thats strange… the underscore in spaces.

Do you know a quick edit for the script to make the popup window open top left of the screen?

Change the “winpops…” line to:

	winpops=window.open(popUrl,"","left=0,top=0,width=400,height=338,resizable,")

I found this site quite useful when working out what settings do what.

Andy

Thanks once again andy