SitePoint Sponsor

User Tag List

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

    Events outside browser.

    Hello, I have a problem with getting events outside of the browser.

    In IE, Chrome and Opera I can catch events outside the browser if I first puts the mousedown in the browser and moves it outside. A simple webpage that does this is here:

    Code:
    <html> 
    <head>
    <script type="text/javascript"> 
    
    function showCoord(e) 
    { 
    	if(document.all)e = event; 
        
    	document.getElementById('mousepos').innerHTML = e.clientX + 'x' + 	e.clientY; 
    } 
    
    </script> 
    </head>
    <body> 
    <div id="mousepos" onclick="document.body.onmousemove = showCoord;" style="background-color:red;width:500px;height:500px"></div> 
    
    
    </body> 
    </html>
    The thing is that in firefox and safari I don't get the mouse coordinates in this app outside the browser even if I have mousedown.

    How can I solve this?

    I know it's possible, becouse on this link:

    dhtmlgoodies.com/packages/dhtml-suite-for-applications/demos/demo-window.html

    there is some windows that can be moved and then draging them they still follow outside the browser even in firefox and safari!

    thanks!

  2. #2
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    clientX will start showing negative numbers (as you want) when the mousedown event has occured. So if you hold ur mouse button down and then move upwards beyond the top of the window you should see that clientX reports negative values. This won't work unless the mouse is 'down'.
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  3. #3
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have alread said that in my post. But the problem is that this doesn't work in firefox or safari, just in IE, Opera and Chrome. So how do you do it in firefox and safari?

  4. #4
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The scenario I described above does work in FF and Safari.
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  5. #5
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you tries the code in my first post in Firefox and safari. It shows the coordinates taken with clientX and clientY and when I press down the mouse and goes outside the main window the coordinates stopps to update so if there is smoething I don't get about your post, please clarify!

    thanks!

  6. #6
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here, I've created a demo page: http://qd9.co.uk/sp/coords.html
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  7. #7
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok...now I know one of the problems.

    The thing is that is works in firefox 3 but not in firefox 2!

    But then again the link I posted in the original post, the one with the windows!

    In there it works in firefox 2 aswell!

    So can it be done in any other way aswell???

    thanks!


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
  •