V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
lanoipd
V2EX  ›  iDev

[问题] js 如何获取在 iframe 内的鼠标移动数据呢?

  •  
  •   lanoipd · 2019-02-25 20:51:08 +08:00 · 3806 次点击
    这是一个创建于 2106 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题描述:

    刚学 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 条回复    2019-02-26 13:26:27 +08:00
    leonlu
        1
    leonlu  
       2019-02-26 13:26:27 +08:00
    不同域名不行
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2547 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 00:22 · PVG 08:22 · LAX 16:22 · JFK 19:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.