multiselect click behaviour mod in IE.

Discussion in 'Javascript' started by Kelly McDonald, Nov 4, 2003.

  1. Hello all,

    Please redirect me if this is the wrong place to post this.

    I have figured out how to make a regular click in a multiselect work
    like a <ctrl>-click in Mozilla, however, I've had a beast of a time
    doing it in IE,
    I have tried stuff like:

    event.cancelBubble = true, event.returnValue = false;
    return false;

    in a handler function. It doesn't seem to matter what level I try to
    capture it at, it still has the same (old) behavior in the multi select
    control (IE 5.5)

    For reference, This works great in Mozilla (1.4) (modified behavior in
    the first multiselect, normal behavior in the second) Any ideas? Thanks!:

    <select id ="selectme" multiple>
    <option>me</option>
    <option>me2</option>
    <option>me3</option>
    </select>

    <select id ="selectme2" multiple>
    <option id="x">me</option>
    <option id="y">me2</option>
    <option id="z">me3</option>
    </select>

    <script language="javascript">
    function mousedown(e)
    {
    if (!e.ctrlKey && !e.shiftKey)
    {
    e.preventDefault();
    e.stopPropagation();
    var evt = document.createEvent('MouseEvents');
    evt.initMouseEvent(
    e.type,
    e.bubbles,
    e.cancelable,
    e.view,
    e.detail,
    e.screenX,
    e.screenY,
    e.clientX,
    e.clientY,
    true,
    false,
    false,
    false,
    0,
    null);
    e.target.dispatchEvent(evt);
    }
    }

    function stopmouse(e)
    {
    alert(e);
    e.preventDefault();
    e.stopPropagation();
    }

    el = document.getElementById("selectme");
    el.addEventListener("mousedown", mousedown, true);
    </script>
     
    Kelly McDonald, Nov 4, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Wittber

    Unexpected mod-python behaviour.

    Simon Wittber, Feb 4, 2004, in forum: Python
    Replies:
    1
    Views:
    264
    Bengt Richter
    Feb 6, 2004
  2. Hari Sekhon
    Replies:
    0
    Views:
    514
    Hari Sekhon
    Jun 20, 2006
  3. ryles
    Replies:
    3
    Views:
    539
    Piet van Oostrum
    Jul 26, 2009
  4. Martin

    Unexpected behaviour of Listbox MultiSelect

    Martin, Oct 18, 2005, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    341
    Steven Cheng[MSFT]
    Jan 24, 2006
  5. T. Onoma
    Replies:
    9
    Views:
    358
    Dave Thomas
    Dec 15, 2003
Loading...

Share This Page