首页   注册   登录
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/
iOS 开发实用书单
iPhone App Development: The Missing Manual
Cocoa and Objective-C: Up and Running
Cocoa Programming for Mac OS X
深入浅出设计模式 Head First Design Patterns
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
V2EX  ›  iDev

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

  •  
  •   lanoipd · 54 天前 · 1165 次点击
    这是一个创建于 54 天前的主题,其中的信息可能已经有所发展或是发生改变。

    问题描述:

    刚学 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
        1
    leonlu   53 天前
    不同域名不行
    关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   2376 人在线   最高记录 4385   ·  
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.3 · 15ms · UTC 14:40 · PVG 22:40 · LAX 07:40 · JFK 10:40
    ♥ Do have faith in what you're doing.
    沪ICP备16043287号-1