x=window.event.x;
y=window.event.y;

解决方案 »

  1.   

    function MouseMove() {
    if (window.event.x != document.test.x.value && window.event.y != document.test.y.value)
     {
    x= window.event.x;
    y= window.event.y;
    }
    }
      

  2.   

    还算可以,我想了一些办法,现在解决了:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="JavaScript">
    <!--
    var s=0;
    var flag=0;
    var x;
    var y;
    function MouseMove()
    {
        if(flag==0)
        return false;
    x= window.event.x;
    y= window.event.y;
    Layer1.style .left =x-50;
    Layer1.style. top=y-50;
     }
    function down()
    {
       flag=1;
    }
    function out()
    {
       flag=0;
    }
    function up()
    {
      flag=0;
    }
    </script>
    </head>
    <body bgcolor="#ffffff" text="#000000">
    <div id="Layer1" onmousemove=MouseMove() onmousedown=down() onmouseout=out() onmouseup=up() style="BORDER-RIGHT: #000000 1px; BORDER-TOP: #000000 1px; Z-INDEX: 1; LEFT: 80px; BORDER-LEFT: #000000 1px; WIDTH: 200px; BORDER-BOTTOM: #000000 1px; POSITION: absolute; TOP: 58px; HEIGHT: 115px; BACKGROUND-COLOR: #ff00ff; layer-background-color: #FF00FF"></div>
    </body>
    </html>