تصف هذه المقالة طريقة الحصول على قيم تنسيق الماوس عبر الإنترنت بواسطة صفحات الويب JS. شاركه للرجوع إليه. طريقة التنفيذ المحددة هي كما يلي:
انسخ الرمز كما يلي: <html>
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = gb2312" />
<title> إظهار إحداثيات الماوس </title>
</head>
<body onMousemove = "micro $ oftmousemove ()">
<script language = "javaScript">
if (navigator.appname == 'netscape')
{
document.captureevents (event.mousemove) ؛
document.onmousemove = netscapemousemove ؛
}
وظيفة netscapeMouseMove (e) {
if (e.screenx! = document.test.x.value && e.screeny! = document.test.y.value) ؛
{
document.test.x.value = e.screenx ؛
document.test.y.value = e.screeny ؛
}
}
وظيفة micro $ oftmousemove () {
if (window.event.x! = document.test.x.value && window.event.y! = document.test.y.value) ؛
{
document.test.x.value = window.event.x ؛
document.test.y.value = window.event.y ؛
}
}
</script>
<name form = "test">
x: <input type = "text" name = "x" size = "4">
y: <إدخال typue = "text" name = "y" size = "4">
</form>
</body>
</html>
آمل أن تكون هذه المقالة مفيدة لبرمجة JavaScript للجميع.