www.webdeveloper.com
Results 1 to 3 of 3

Thread: Need Code Browser fix

  1. #1
    Join Date
    Sep 2006
    Posts
    10

    Need Browser Code fix

    Hello i made a small javascript hover layer code that follows a mouse when over an image and it works perfectly fine on IE but is having problems working in firefox, if u can then can you please turn my code into a cross browser and in explaination either one will be very very helpfull thank you
    Code:
    <script language="JavaScript1.2">
    <!--
    var IE = document.all?true:false
    if (!IE) document.captureEvents(Event.MOUSEMOVE)
    document.onmousemove = getMouseXY;
    var tempX = 0
    var tempY = 0
    function getMouseXY(e) {
      if (IE) {
        tempX = event.clientX + document.body.scrollLeft
        tempY = event.clientY + document.body.scrollTop
      } else {
        tempX = e.pageX
        tempY = e.pageY
      }  
      if (tempX < 0){tempX = 0}
      if (tempY < 0){tempY = 0}  
      return true
    }
    function showDiv(dname){
    	document.getElementById(dname).className="showDiv";
    	document.getElementById(dname).style.top=tempY;
    	document.getElementById(dname).style.left=tempX+10;
    }
    function hideDiv(dname){
    	document.getElementById(dname).className="hideDiv";
    }
    //-->
    </script>
    a working example of this is found on http://wow.lod-gaming.net/meh.html
    Last edited by dxillusion; 09-16-2006 at 11:15 PM.

  2. #2
    Join Date
    Nov 2003
    Location
    Canada
    Posts
    1,592
    You always need to use units
    Code:
    document.getElementById(dname).style.top=tempY+'px';
    document.getElementById(dname).style.left=tempX+10+'px';

  3. #3
    Join Date
    Sep 2006
    Posts
    10
    thanx a alot and i really feel stupid for not thinking that =P

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles