我遇到了这样一个问题
鼠标点击图片,提交鼠标相对图片的位置(即x值)
下面是相关代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<script language="JavaScript">
function submitform() {
//document.form1.submit();
alert(document.form1.x.value);
}
function icxy(event) {
image = event.offsetX?(event.offsetX):event.pageX-document.getElementById("cxy").offsetLeft;
document.form1.x.value = image;
}
</script>
</head><body style="margin:0">
<p>Test</p>
<FORM method=post name=form1>
<div id="cxy" style="margin:0 auto;width:270px; height:129px; border:#F00 1px solid"" onclick="submitform(icxy(event))">
<center><img src="http://www.baidu.com/img/baidu_sylogo1.gif"></center>
</div>
<INPUT type=hidden name=x>
</FORM>
</body>
</html>
设置鼠标位置,可以正常提交
我现在想不移动鼠标,实现自动点击
怎么实现这个功能
鼠标点击图片,提交鼠标相对图片的位置(即x值)
下面是相关代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<script language="JavaScript">
function submitform() {
//document.form1.submit();
alert(document.form1.x.value);
}
function icxy(event) {
image = event.offsetX?(event.offsetX):event.pageX-document.getElementById("cxy").offsetLeft;
document.form1.x.value = image;
}
</script>
</head><body style="margin:0">
<p>Test</p>
<FORM method=post name=form1>
<div id="cxy" style="margin:0 auto;width:270px; height:129px; border:#F00 1px solid"" onclick="submitform(icxy(event))">
<center><img src="http://www.baidu.com/img/baidu_sylogo1.gif"></center>
</div>
<INPUT type=hidden name=x>
</FORM>
</body>
</html>
设置鼠标位置,可以正常提交
我现在想不移动鼠标,实现自动点击
怎么实现这个功能
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货