JS get mouse coordinate position compatible with multiple browsers

Source: Internet
Author: User
Tags gety

This is available when the next view test is compatible under IE 11.

$ (window). Bind ('Beforeunload', Function (Event) {    var_this = This; varx =Event. Originalevent.clientx; vary =Event. Originalevent.clienty; if(X >Event. currentTarget.document.body.clientWidth && Y <0||Event. Altkey) {       //alert ("OK");$.post ("/admin/login/clearsesssion", Function (response) {//$ ("#myPnl"). HTML (response);        }); }});

This seemingly simple to get coordinates function, but has spent my day, the day has been searching JS get coordinates, find a lot of many, one test, the result is incompatible. Really enough irritability, but things still want to continue, to complete, come back and continue to practice, search, repeated operation, found himself a lot of not ah, especially the jquery custom method (function), not at all, very lack of foundation, secretly determined to finish this study JS, otherwise always stuck in this respect. Although the time is long past, but I still did not give up, think of a keyword search, is not able to find what I want. Search "JS get coordinates compatible IE8", suddenly appeared after a few, so choose a practice, transformation, Kung Fu is not a conscientious, finally appeared I want results. Thanks to the network, thanks to the Netizen, solves the problem which bothers me day. Post the code found on the Web.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 

The code I needed after my makeover

Press CTRL + C to copy the code<textarea></textarea>Press CTRL + C to copy the code

The following IE7,IE8 is not compatible and some browsers can


function Getpostion (e) {
var x = GetX (e);
var y = GetY (e);
}
function GetX (e) {
E = e | | window.event;

return E.pagex | | E.clientx + document.body.scroolLeft;
}

function GetY (e) {
E = e| | window.event;
return E.pagey | | E.clienty + Document.boyd.scrollTop;
}

To summarize, the information retrieval is really important, is to learn to ask questions, search for keywords.

Transferred from: http://www.cnblogs.com/annabook/p/4506614.html

JS get mouse coordinate position compatible with multiple browsers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.