...

View Full Version : Drop-down list not opening new window



udee
02-24-2012, 12:02 PM
New member here. Hope y'all can help with a frustrating issue I have.

SYSTEM INFO:
I'm on an Apple MacBook Pro running OS X v10.7.3 (Safari v5.1.3).

PURPOSE:
I want to create a drop-down list of web sites I like. When the user selects an item, I want the browser to open a new window (or tab) with the URL provided.

THIS WORKS (but, as expected, content is placed in current window):
<form>
<select name="URL" OnChange="location.href=this.form.URL.options[selectedIndex].value">
<option value="" selected><b>Your network info ...</b></option>
<option value="http://www.aws.com/support/faq/software/ip.asp">Your IP address</option>
<option value="http://www.beelinebandwidthtest.com/">Your bandwidth speed (option 1)</option>
<option value="http://reviews.cnet.com/Bandwidth_meter/7004-7254_7-0.html">Your bandwidth speed (option 2)</option>
<option value="http://www.spamhaus.org/lookup.lasso">Spamhaus IP check</option>
</select>
</form>


BUT THIS DOESN'T WORK WHY NOT? Expecting a new window (or tab) to be created.:
<form>
<select name="URL" OnChange="window.open(this.form.URL.options[selectedIndex].value)">
<option value="" selected><b>Your network info ...</b></option>
<option value="http://www.aws.com/support/faq/software/ip.asp">Your IP address</option>
<option value="http://www.beelinebandwidthtest.com/">Your bandwidth speed (option 1)</option>
<option value="http://reviews.cnet.com/Bandwidth_meter/7004-7254_7-0.html">Your bandwidth speed (option 2)</option>
<option value="http://www.spamhaus.org/lookup.lasso">Spamhaus IP check</option>
</select>
</form>


FYI INTERESTINGLY, THE "window.open" CODE *DOES* WORK FOR A BUTTON. HMMMM.
<form>
<input type="button" value="Open Window" onclick="window.open('http://www.about.com')">
</form>


Anyone have a suggestion on what I'm doing wrong with the <SELECT OnChange=window.open()> event?

-- Udee

Logic Ali
02-24-2012, 01:01 PM
Your code does work on other clients. Try simplifying it to window.open( this.value )

Lerura
02-25-2012, 12:07 AM
per definition window.open requires an URL and a window name. eg.:
window.open('http://www.google.com/', 'NewWindow');

Maybe Apple for OSx is very strict here.

Or maybe you have checked "Block Extra Windows" under settings

glenngv
02-25-2012, 02:40 PM
You only have to open the popup when option value is not empty to exclude the first option.


<select name="URL" onchange="if (this.value) window.open(this.value, '_blank');">

Pepperfly
04-14-2012, 10:12 AM
I've been scouring the web for days looking for a javascript dom example just like this. I've seen so many, but I tested this one and it is (almost) perfect!

It's almost perfect for me because I really don't want my form to submit onchange. How do I implement a submit button, instead?

glenngv
04-14-2012, 12:44 PM
Is this what you needed?

<form>
<select name="URL">
<option value="">Your network info ...</option>
<option value="http://www.aws.com/support/faq/software/ip.asp">Your IP address</option>
<option value="http://www.beelinebandwidthtest.com/">Your bandwidth speed (option 1)</option>
<option value="http://reviews.cnet.com/Bandwidth_meter/7004-7254_7-0.html">Your bandwidth speed (option 2)</option>
<option value="http://www.spamhaus.org/lookup.lasso">Spamhaus IP check</option>
</select>
<input type="button" value="Open Window" onclick="if (this.form.URL.value) window.open(this.form.URL.value);" />
</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum