Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Please help: On list box change event open new url in current window

Reply
Thread Tools

Please help: On list box change event open new url in current window

 
 
Paul
Guest
Posts: n/a
 
      10-16-2003
Hi,

How do I on the change event of a list box open a new url in the
current window in which the list box resides. I'm not using frames.

Thanks,

Paul
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      10-16-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Paul) writes:

> How do I on the change event of a list box open a new url in the
> current window in which the list box resides. I'm not using frames.


I assume you mean a select element, not a "list box".

<select onchange="location.href=this.options[this.selectedIndex].value">
<option value="http://www.google.com">Google!</option>
<option value="http://www.google.com">Google again!</option>
</select>

However(!), you should not make a destructive update in an onchange
handler for a select element. People navigating with the keyboard will
not be able to reach anything but the first option. It also breaks with
the expected behavior of a select element: something you change, and
makes it act more like, e.g., a button: something that makes things
happen. It is bad for usability to go against the users' expectations.

/L
--
Lasse Reichstein Nielsen - (E-Mail Removed)
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      10-19-2003
Lasse Reichstein Nielsen wrote:
> (E-Mail Removed) (Paul) writes:
>> How do I on the change event of a list box open a new url in the
>> current window in which the list box resides. I'm not using frames.

>
> I assume you mean a select element, not a "list box".
>
> <select onchange="location.href=this.options[this.selectedIndex].value">
> <option value="http://www.google.com">Google!</option>
> <option value="http://www.google.com">Google again!</option>
> </select>
>
> However(!), you should not make a destructive update in an onchange
> handler for a select element. People navigating with the keyboard will
> not be able to reach anything but the first option. [...]


Depends. People navigating with the keyboard can use the Alt+$Cursor
key combination to dropdown the list in some UAs when size="1" is used.
Then the `onchange' handler fires only when they confirm their selection
with the Return key.

In ordinary lists you're right: The onchange handler should not be used
there.


PointedEars

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printing out the current URL for current ASP page in Perl Jack Perl Misc 3 12-22-2008 02:35 PM
Possible to show an iframe's current location (current URL) liketofindoutwhy@gmail.com Javascript 1 03-19-2008 10:20 PM
We Buy and Sell New, Used, Refurbished and New Open Box Cisco Systems, Extreme Networks, F5 Networks and Compaq equipment at up to 90% off list! burke.bruce@gmail.com Cisco 1 10-16-2006 10:51 AM
Solution: Raising an Event Handler Postback on Parent Window From Popup Child Window Dialog Box Earl Teigrob ASP .Net 1 06-16-2004 04:19 PM
window.open() doesn't open new Window in Opera PC HUA Javascript 2 05-19-2004 02:29 AM



Advertisments