<script language="JavaScript">
function handleMouse() {
alert("mouse position = (" + window.event.x + "," + window.event.y + ")");
}
</script>
<body onclick="handleMouse()">
Please click your mouse
function handleMouse() {
alert("mouse position = (" + window.event.x + "," + window.event.y + ")");
}
</script>
<body onclick="handleMouse()">
Please click your mouse
写到服务器需要提交到Asp,用Asp写文件。具体可以用FileSystemObject
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>
看来你是
javascript的高手阿!
function handleMouse() {
alert("(" + window.event.x + "," + window.event.y + ")");
}
</script>
<br>
<br>
<br>
<img width="400" height="300" style="position:relative;" onclick="handleMouse()">
document.body.scrollTop+event.clientY;