View Full Version : Dropdowns,when clicked,opens at a new window

01-01-2007, 04:26 PM
Hi Let me ask that when we click in dropdowns there is a new window that opens (a href's).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>As if worked...</TITLE>
<style type="text/css">
select{background-color: darkcyan;font-family: verdana;font-size:10px;font-weight: bold}
select:hover {background-color: cyan; font-family:verdana;font-size: 10px;font-weight: bold}
.one {border: 1px solid #ffffff}
a:link,a:visited {color: darkcyan;text-decoration: none}
a:hover{color: cyan}
hr.one {border-top: inset #ffffff}
hr.two {border-bottom: inset #ffffff}
<BODY bgcolor="#000000" text="#000000">
<IMG src="01049.gif" width="798" height="22" align="top" alt="As if worked..." style="position:absolute;left:0px;top:0px;width:798px;height:22px;z-index:0" class="one">
<DIV style="position:absolute;left:9px;top:24px;width:787px;height:23px;background-color:#000000;z-index:1" align="left">
<MARQUEE direction="right" height="23" scrolldelay="90" scrollamount="6" behavior="scroll" loop="0" style="font-family:Verdana;font-size:11px;font-weight:bold;text-decoration:none;color:#00FF00;background-color:#000000;">Welcome to my site---Works best in firefox!!!</MARQUEE>
<DIV style="position:absolute;left:13px;top:72px;width:618px;height:39px;z-index:2" align="left">
<FONT style="font-size:11px" color="#FFFF00" face="Verdana"><B>Whaaaaaaaaaaaaaaaaaaaaat now...Where will I go...What is the content???</B></FONT><FONT style="font-size:11px" color="#FFFFFF" face="Verdana"><B><BR>
Just click on one of the links in the <BR>
combobox and tell you a lot of info about them...</B></FONT>
<HR width="383" color="#000000" style="position:absolute;left:13px;top:52px;width:383px;height:3px;z-index:3" class="one">
<HR noshade size="3" width="383" color="#000000" style="position:absolute;left:15px;top:114px;width:383px;height:3px;z-index:4" class="two">
<DIV style="position:absolute;left:535px;top:71px;width:277px;height:155px;z-index:5" align="left">
<option onclick="location.href=''">Improve your browser</option>
<option onclick="location.href=''">Games I play</option>
<option onclick="loction.href=''">Coding (e.g. HTML CSS)</option>
<option onclick="location.href=''">Getting to know your browser</option>

01-01-2007, 04:30 PM
At line 30-35 is where u'll find the select and options...

01-01-2007, 06:09 PM
I'm not sure whether anchors can be children of options, but if you do that, with a target of '_blank', it should work.

01-01-2007, 09:06 PM
You would code the select list something like this:

function newWindow() {
if (this.value) {
var w = window.open();
w.location = this.value;

<select onchange="newWindow()">
<option value="" selected="selected">ó Select Destination ó</option>
<option value="URI">Improve your browser</option>
<option value="URI">Games I play</option>
<option value="URI">Coding (e.g. HTML CSS)</option>
<option value="URI">Getting to know your browser</option>

Note that I added a dummy element at the top. This is because onchange requires a change. If the user wants to go to the first destination, and the initially selected option is the one that refers to that destination, then selecting that option will result in no change and the change event will not be triggered. If you donít want a dummy option and would like to circumvent that issue, you could add a submit/go‐to button.

And just so you know, a select list is not a very good way to implement site navigation. The user cannot control whether they want the destination to open in the current window, a new window, a new tab, to save the file, etc. Without anchor elements, the user also doesnít see the link destination in their browserís status bar. Finally, the user canít navigate at all when JavaScript is disabled.

Forcing the user to open a new window without good reason (i.e., to keep them on your site) is also not very user‐friendly especially when you donít give a warning (text, icon, etc) indicating that a new window will be (forcibly) opened.

I'm not sure whether anchors can be children of options, but if you do that, with a target of '_blank', it should work.They canít.