e.FLY

js判断浏览器/获取鼠标坐标/鼠标按键
View Code
 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3     <head>
 4         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 5         <title>Untitled Document</title>
 6         <script type="text/javascript" src="jquery-1.6.2.js"></script>
 7         <style type="text/css">
 8             *{
 9                 margin:0px;
10                 padding:0px;
11             }
12             body div{
13                 border:1px solid black;
14                 text-align:center;
15                 margin:auto;
16                 /*float:inherit;
17                 position:absolute;*/
18             }
19             
20         </style>
21         <script type="text/javascript">
22             $(function(){
23                 $("div").mouseover(function(e){
24                     var b_version=navigator.appVersion
25                     var version=parseFloat(b_version)
26                     if(version>4){
27                         if(e.which==1){
28                             $(this).css("cursor","hand");
29 //                            document.write("left:"+this.left)
30                         }
31                     }
32                 });
33                 $(".div").mouseover(function(event){
34 //                    alert(e.which);//弹出鼠标按键码。1表示按下左键.
35 //                    alert(event.button);//判断鼠标按键码.0为左键,2为右键///
36                     $(this).css({"cursor":"hand","position":"absolute"});
37                     x=event.clientX;
38                     y=event.clientY;
39 //                    alert("X 坐标: " + x + ", Y 坐标: " + y)
40                 });
41                 $(".div").mouseup(function(event){
42                     $(this).css("top":event.clientY,"left":event.clientX);
43                 });
44             })
45             
46             //alert(navigator.appName);//判断浏览器
47             document.write("<p>浏览器:")
48             document.write(navigator.appName + "</p>")
49             
50             document.write("<p>浏览器版本:")
51             document.write(navigator.appVersion + "</p>")
52             
53             var b_version=navigator.appVersion
54             var version=parseFloat(b_version)
55             document.write("version:"+version)
56             
57             document.write("<p>代码:")
58             document.write(navigator.appCodeName + "</p>")
59             
60             document.write("<p>平台:")
61             document.write(navigator.platform + "</p>")
62             
63             document.write("<p>Cookies 启用:")
64             document.write(navigator.cookieEnabled + "</p>")
65             
66             document.write("<p>浏览器的用户代理报头:")
67             document.write(navigator.userAgent + "</p>")
68         </script>
69     </head>
70     <body>
71         <div style="width:400px;height:400px;">
72             <div style="width:100px;height:100px;" class="div"></div>
73             <div style="width:100px;height:100px;"></div>
74             <div style="width:100px;height:100px;"></div>
75         </div>
76     </body>
77 </html>

 

posted on 2012-04-11 20:41  e.FLY  阅读(438)  评论(0)    收藏  举报