SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Onmouseover in IE

    I have having some trouble with getting this to work in IE, it works perfect in firefox.

    Here is the code:
    Code:
    <script type="text/javascript">
    window.addEvent=function(e,ev,f,c){if(e.addEventListener){e.addEventListener(ev,f,c);}else if(e.attachEvent){var r=e.attachEvent('on'+ev,f);return r;}else{e['on'+ev]=f;}};
    
    function all(){
    	document.write('SOMETHING HERE');
    
    	function mouseover()
    	{
     		alert('onmouseover');
    	}
    
    window.onmouseover = mouseover;
    }
    
    window.addEvent(window, "load", all, false);
    </script>
    Why doesn't it work in IE? Is there a way to do this that works in all browser?

    Thanks!

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about document.onmouseover instead of window.onmouseover ?
    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again for the quick solution hexburner. It works

  4. #4
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It actually didn't work.

    I thought it worked at first but I accidently commented out the :
    document.write('SOMETHING HERE');

    thats why it worked, but when I un-commented the document.write it doesn't work.

    Why is this causing a problem? its working in firefox.

    Any help would be appreciated! Thanks.

  5. #5
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apparently, don't ask why, IE doesn't support document.onmouseover or document.onmouseout...
    FOR SALE: 1 set of morals, never used, will sell cheap

  6. #6
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It seems the problem have to do something with the document.write, because when I comment that out it seems to be working.

    I need to document.write to replace the current html/text on screen so it have be done onload.

    Is there any alternative solution?

    Thanks.
    Last edited by javalearnie; Jun 11, 2007 at 18:52.

  7. #7
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can try document.body.appendChild(document.createTextNode('Some text here'));
    FOR SALE: 1 set of morals, never used, will sell cheap


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
  •