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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

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

    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
  • Lasse Reichstein Nielsen

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

    paulsmith5@hotm ail.com (Paul) writes:
    [color=blue]
    > 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.[/color]

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

    <select onchange="locat ion.href=this.o ptions[this.selectedIn dex].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 - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: Please help: On list box change event open new url in currentwindow

      Lasse Reichstein Nielsen wrote:[color=blue]
      > paulsmith5@hotm ail.com (Paul) writes:[color=green]
      >> 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.[/color]
      >
      > I assume you mean a select element, not a "list box".
      >
      > <select onchange="locat ion.href=this.o ptions[this.selectedIn dex].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. [...][/color]

      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

      Comment

      Working...