Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Event Handling - IE vs Mozilla (noob q)

    OK, I'm sure this is familiar to many of you, but I'm just starting out with this. Anyway, I'm trying to get a little script to basically hide and show content. Works fine in Mozilla/Fx but not (surprise) in IE. Any help would be much appreciated.

    Chris

    Code:
    var fnMouseOver1 = function()
    {
    document.getElementById("Tracks2").style.display = "none";
    document.getElementById("Tracks1").style.display = "block";
    document.getElementById("st1").style.display = "none";
    document.getElementById("st2").style.display = "inline";
    };
    
    var fnMouseOver2 = function()
    {
    document.getElementById("Tracks2").style.display = "block";
     document.getElementById("Tracks1").style.display = "none";
     document.getElementById("st1").style.display = "inline";
     document.getElementById("st2").style.display = "none";
    };
    
    window.onload = function()
    {
     if(document.getElementById("st1").addEventListener ) 
      {
      document.getElementById("st1").addEventListener('mouseover',fnMouseOver1,true);
      document.getElementById("st2").addEventListener('mouseover',fnMouseOver2,true);
      } 
    else if ( document.getElementById("st1").attachEvent ) 
      {
      document.getElementById("st1").attachEvent('mouseover',fnMouseOver1);
      document.getElementById("st2").attachEvent('mouseover',fnMouseOver2);
      };
    }

  • #2
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Keep in mind that some browsers, like IE5/Mac don't support either of those event models -- they only support the DOM0 event model.

    Code:
      document.getElementById("st1").attachEvent('mouseover',fnMouseOver1);
      document.getElementById("st2").attachEvent('mouseover',fnMouseOver2);
    should be
    Code:
      document.getElementById("st1").attachEvent('onmouseover',fnMouseOver1);
      document.getElementById("st2").attachEvent('onmouseover',fnMouseOver2);
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #3
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. I feel like a real noob for not spotting that

    Chris

  • #4
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why? The two event models handle that differently. It's easy to make an incorrect assumption that they would handle that the same way.

    You're welcome
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Most of the time the simple, trusty and crossbrowser DOM 0 methods do very all kinda jobs, including this one:

    document.getElementById("st1").onmouseover=fnMouseOver1;
    document.getElementById("st2").onmouseover=fnMouseOver2;

    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for that. The simpler things are the more I like it

  • #7
    New Coder
    Join Date
    Jul 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hi

    hello all,
    I know this is a wrong place to place this post .. but i cudnt find a better one.. i was searching for some design details or some kind of pseudo code which would help in handling events from the browser end.. this event handling is mainly for the browser for a handheld device..
    can i get some help or lead on the same ..

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Give us more details. And better simple start a new thread with this problem.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #9
    New Coder
    Join Date
    Jul 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hi kor

    thanx for showing interest...
    I was actually working on builiding the event handling module for a mobile intrenet browser.. so i was kind of looking for how in general event handling happens in a browser(preferably mobile browser)... so any inputs on the code flow from capturing of events till execution of scripts or similar things would be helpful...
    can i get any information on the design and flow......

  • #10
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Unfortunatelly, the event capture/handling codes are different and works different from a browser type to another. What kinda browser are u to use on?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #11
    New Coder
    Join Date
    Jul 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hi ther

    I am working on developing a browser for mobile device, currently its on wince platform and this browser would be mainly used for handheld devices like pda or mobile phones...
    i assume the capturing of the events would be different based on the ui we have whereas the handling would have some kind of standard flow.
    so putting it across its basically a browser for handheld device.. hope some more light would be shed by u on the same..


  •  

    Posting Permissions

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