Forum Moderators: open
I use the form below to create a drop-down menu for navigation.
Is there any way to have the selection open in a new window. I've found how to redirect the selections for the whole form, but is there any way to just redirect one or two individual selections ...say, "Page 4" and "Page 5, to open in a new window while the remaining selections open in the parent window. Any and all suggestions would be appreciated.
Joseph
<FORM> ...OR GO TO
<SELECT NAME="URL" onChange="if(options[selectedIndex].value)window.location.href=(options[selectedIndex].value)">
<OPTION SELECTED VALUE="">Another Page: </OPTION>
<OPTION VALUE="Page1.html">Page1</OPTION>
<OPTION VALUE="Page2.html">Page2</OPTION>
<OPTION VALUE="Page3.html">Page3</OPTION>
<OPTION VALUE="Page4.html">Page4</OPTION>
<OPTION VALUE="Page5.html">Page5</OPTION>
</SELECT>
</FORM>
<script language="javascript">
function goToURL(oSelect){
var _value = oSelect.options[this.selectedIndex].value;
if (_value!= "") {
var _target = _value.split("¦")[0];
var _url = _value.split("¦")[1];
if (_target == "new"){
window.open(_url);
}else{
window.location.href=_url;
}
}
}
</script>
<FORM> ...OR GO TO
<SELECT NAME="URL" onChange="goToURL(this)">
<OPTION SELECTED VALUE="">Another Page: </OPTION>
<OPTION VALUE="new¦Page1.html">Page1</OPTION>
<OPTION VALUE="new¦Page2.html">Page2</OPTION>
<OPTION VALUE="new¦Page3.html">Page3</OPTION>
<OPTION VALUE="self¦Page4.html">Page4</OPTION>
<OPTION VALUE="self¦Page5.html">Page5</OPTION>
</SELECT>
</FORM>
-=casey=-
Thanks for the reply. I modified my form and added to the page the javascript you supplied, but nothing happened. Not only did it not accomplish what I'd hoped for (opening the target in a new window), but nothing happens at all.
I don't know enough about javascripting to even begin to "analyze" this. I can only say, thanks for the attempt.
Joseph
There are two things wrong with the code:
1. A quick change needed
var _value = oSelect.options[this.selectedIndex].value;
//to//
var _value = oSelect.options[oSelect.selectedIndex].value;
2. This one isn't casey's fault.
WebmasterWorld changes the pipe char ¦ into what yop see - a broken pipe.
Change all broken pipes in the code into unbroken pipes.
(or use a different delimiter entirely).