SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member dmose's Avatar
    Join Date
    Aug 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Onmousemove in a select list not working in IE but works in FF

    Greetings,

    I'm trying to update a div display as the user moves through each item in a select list. The code works fine in FF ..but fails in IE...

    IE doesnt seem to like assigning functions to events to OPTION tags ? Any ideas?

    HTML Code:
       <select id="ddlMain" style="width: 200px;">            
                <option value=""></option>
                <option value="SomeValue1">SomeValue1</option>
                <option value="SomeValue2">SomeValue2</option>
                <option value="SomeValue3">SomeValue3</option>
                <option value="SomeValue4">SomeValue4</option>
                <option value="SomeValue5">SomeValue5</option>            
            </select>
     <span id="dvStatus"></span> 
    <script type="text/javascript">   
    
       function init(){
            var the = document.getElementById('ddlMain');   
             for(var i=0;i<the.options.length;i++){            
                 the.onmousemove  = function(event){      //this doesnt work in IE for some reason...                                
                    document.getElementById('dvStatus').innerHTML = new Date().getMilliseconds().toString();
                }
             }
         }
    
        window.onload = init; 
    
    </script>

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IE doesnt seem to like assigning functions to events to OPTION tags
    This is true, options do not respond to most events in IE - check out the microsoft documentation about options and which events are available:
    http://msdn2.microsoft.com/en-us/lib...77(VS.85).aspx

    However, your code isn't assigning events to options. It's assigning an event to the select over and over again.
    Code:
    the.onmousemove  = function....
    
    //maybe you meant
    the.options[i].onmousemove....
    Anyway, it's not gonna work in IE. Maybe there's another way to do it?

  3. #3
    SitePoint Member dmose's Avatar
    Join Date
    Aug 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jimfraser View Post
    This is true, options do not respond to most events in IE - check out the microsoft documentation about options and which events are available:
    http://msdn2.microsoft.com/en-us/lib...77(VS.85).aspx

    However, your code isn't assigning events to options. It's assigning an event to the select over and over again.
    Code:
    the.onmousemove  = function....
    
    //maybe you meant
    the.options[i].onmousemove....
    Anyway, it's not gonna work in IE. Maybe there's another way to do it?
    You're correct the code I posted is wrong, however that was after playing around with it for a bit - even "the.options[i].eventname' doesn't work as expected.

    As far as I know there is no work around - the only thing I've seen is assigning ID's to each option, then locating them on global mousemove using coordinates etc its very nasty..

    I'm surprised MS didn't support these events like FF does - and I'm also suprised not many people need this type of functionality


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •