刚学 js,求问大家这种情况下怎么改,获取鼠标移动数据的 js 在父页面,但是想要获取鼠标在 iframe 内的移动数据,设置了 timeout 还是获取不到?应该怎么改呢?
<body onload="alertNum();browerInfo()" onkeydown="keyDown()" onkeyup="keyUp()" onmousedown="mousedown_sendXML()" onmousemove="mousemove_sendXML()" onmouseup="mouseup_sendXML()">
<iframe name="wenjuan" id="wenjuan" frameborder="0" height="1200" width="1600" z-index=100 src="https://wj.qq.com/s2/2885356/2b08/" frameborder="0" allowfullscreen></iframe>
function mousemove_sendXML(){
var d = (new Date()).valueOf();
var iframe = document.getElementById("wenjuan");
//var iwindow = iframe.contentWindow;
var e = window.event || arguments.callee.caller.arguments[0] || iwindow.event;
var x = e.screenX ;
var y = e.screenY ;
StringData=StringData+"miaosha1"+" "+"mousemove"+" "+x+" "+y+" "+d+"\n";
document.getElementById("StrData").value = StringData;
var clientX=e.clientX;
var clientY=e.clientY;
strCilent=strCilent+"miaosha1"+" "+"mousemove"+" "+clientX+" "+clientY+" "+d+"\n";
document.getElementById("StrData2").value = strCilent;
setTimeout(getdata,1000);
function getdata() {
var cX=e.screenX;
var cY=e.screenY;
strData3=strData3+"miaosha1"+" "+"mousemove"+" "+cX+" "+cY+" "+d+"\n";
document.getElementById("StrData3").value = strData3;
}}
--
1
lanoipd OP 求问
|
2
1762628386 2019-02-25 22:12:31 +08:00
用 postMessage
|
3
whwq2012 2019-02-25 22:20:31 +08:00 via Android
同问,我也有类似的问题,怎么操作嵌套多次的 iframe 里的元素
|
4
gzlock 2019-02-25 22:39:10 +08:00
没办法操作跨域的 iframe 吧
|
5
shijianit 2019-02-25 22:52:33 +08:00
跨域的 iframe,进行不了任何操作
|
6
sparkinglemon 2019-02-25 22:53:43 +08:00
2L 正解,可以参考一下
https://juejin.im/post/590c3983ac502e006531df11 |
7
beastk 2019-02-26 09:21:13 +08:00 via iPhone
跨域了,别想了
|
8
MrKou47 2019-02-26 10:47:29 +08:00 via iPhone
postMessage +1
|