我有一个占据整个窗口的iframe(100%宽,100%高),我需要主窗口才能检测鼠标移动的时间.
已经onMouseMove在iframe上尝试了一个属性,它显然不起作用.还尝试将iframe包装在div中,如下所示:
<div onmousemove="alert('justfortesting');"><iframe src="foo.bar"></iframe></div>
Run Code Online (Sandbox Code Playgroud)
..它没有用.有什么建议?
我正在我的网页上的div中加载一个外部网页(在本例中为www.duckduckgo.com).我希望在div内外得到我的鼠标X和Y位置,但当我在div内部时,似乎网页阻止onmousemove事件发射.但是,onmouseover事件在进入div时仅触发一次.
以下示例代码说明了我的问题:
function mouseEvent(event) {
var x = event.clientX;
var y = event.clientY;
document.getElementById('label').innerHTML = 'X=' + x + ' Y=' + y;
}Run Code Online (Sandbox Code Playgroud)
html {
height: 100%;
width: 100%;
}
body {
height: 100%;
width: 100%;
overflow: hidden;
margin-left: 0px;
margin-top: 0px;
margin-bottom: 0px;
margin-right: 0px;
}
#form1 {
height: 100%;
width: 100%;
}
#pageDiv {
height: 100%;
width: 100%;
}
#page {
height: 100%;
width: 100%;
}Run Code Online (Sandbox Code Playgroud)
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body> …Run Code Online (Sandbox Code Playgroud)