SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2008
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Firefox not passing event

    I've basically copied this script from somewhere so i can figure it out (my old script didn't work either). The main problem i'm having is that when the script runs i get the error that e has no properties.. so how do i get firefox to pass it?

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    </head>
    <script type="text/javascript">
    
    function showbubble(e) {
    	
    	var posx = 0;
    	var posy = 0;
    	if (!e) var e = window.event;
    	if (e.pageX || e.pageY) 	{
    		posx = e.pageX;
    		posy = e.pageY;
    	}
    	else if (e.clientX || e.clientY) 	{
    		posx = e.clientX + document.body.scrollLeft
    			+ document.documentElement.scrollLeft;
    		posy = e.clientY + document.body.scrollTop
    			+ document.documentElement.scrollTop;
    	}
    	offsetx = 10
    	offsety = 10
    	x = posx+offsetx
    	y = posy+offsety
    	
    	document.getElementById("debug").innerHTML = "x: " + x + ", y:" + y
    }
    </script>
    <body onmousemove="showbubble()">
    <div id="debug"></div>
    </body>
    If anyone can see a problem with that can they point it out - as i really have no idea where it's going wrong.

  2. #2
    SitePoint Zealot
    Join Date
    May 2008
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to try something like this
    Code:
    var myEvent = e ? e : window.event; 
    	if (myEvent.pageX || myEvent.pageY) 	{
    		posx = myEvent.pageX;
    		posy = myEvent.pageY;
    	}
    	else if (myEvent.clientX || myEvent.clientY) 	{
    		posx = myEvent.clientX + document.body.scrollLeft
    			+ document.documentElement.scrollLeft;
    		posy = myEvent.clientY + document.body.scrollTop
    			+ document.documentElement.scrollTop;
    	}
    renkai.com

  3. #3
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <body onmousemove="showbubble(event);">

  4. #4
    SitePoint Member
    Join Date
    May 2008
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pepejeria View Post
    Code:
    <body onmousemove="showbubble(event);">
    I'm sure thats what i had originally... But obviously not - it's working now, thank you

    Thank you for your post aswell renkai, i tried the code but had the same problem as my first attempt.


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
  •