<script language="JavaScript">
function handleMouse() {
alert("mouse position = (" + window.event.x + "," + window.event.y + ")");
}
</script>
<body onclick="handleMouse()">
Please click your mouse

解决方案 »

  1.   

    直接在Client写文件是不好的,从安全考虑,浏览器是不允许直接写文件到Client的
    写到服务器需要提交到Asp,用Asp写文件。具体可以用FileSystemObject
      

  2.   

    对不起!我对ASP不了解!你给我一段吗可以吗!下面30分等你啊
      

  3.   

    两个文件:调用test.asp
    test.asp:
    <script language="JavaScript">
    function handleMouse() {
    document.formname.MousePosition.value = window.event.x + "," + window.event.y;
    }
    </script>
    <body onclick="handleMouse()">
    Please click on the window and click button to save mouse position
    <form name="formname" method="post" action="save.asp">
    <input type="button" value="Save to file" onclick="document.formname.submit()">
    <input type="hidden" name="MousePosition" value="0,0">
    </form>
    save.asp
    <%
    Dim fso, ts, sMousePosition, sFilePathsMousePosition = Request("MousePosition")
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    sFilePath = Server.MapPath(".") & "\mouseposition.txt"
    Set ts = fso.CreateTextFile(sFilePath, True)
    ts.WriteLine(sMousePosition)
    ts.Close
    Set ts = Nothing
    Set fso = Nothing
    %>
    <a href="mouseposition.txt">See Result</a>
      

  4.   

    谢谢!
    看来你是
    javascript的高手阿!
      

  5.   

    哦,没那么麻烦:<script language="JavaScript">
    function handleMouse() {
    alert("(" + window.event.x + "," + window.event.y + ")");
    }
    </script>
    <br>
    <br>
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp;<img width="400" height="300" style="position:relative;" onclick="handleMouse()">
      

  6.   

    原来我也碰到了如此问题。这样可避免滚动窗口的问题。document.body.scrollLeft+event.clientX;
    document.body.scrollTop+event.clientY;
      

  7.   

    http://lucky.myrice.com/javascriptexam/mousepos2.php