• iframe添加点击事件



    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jquery</title>
    <style type="text/css">
    </style>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
    <script type="text/javascript">

    </script>
    </head>
    <iframe src="http://code.artcare.com/page/light-pulses/" width="100%" height="100%" scrolling="no" frameborder="0" id="iFrame"></iframe>
    <input type="text" id="btn" style=" 0; height: 0;position: absolute; left: -100000">

    <script>

    var IframeOnClick = {
    resolution: 200,
    iframes: [],
    interval: null,
    Iframe: function () {
    this.element = arguments[0];
    this.cb = arguments[1];
    },
    track: function (element, cb) {
    this.iframes.push(new this.Iframe(element, cb));
    var _this = this;
    this.interval = setInterval(function () {
    _this.checkClick();
    }, this.resolution);
    },
    checkClick: function () {
    if (document.activeElement) {
    var activeElement = document.activeElement;
    for (var i in this.iframes) {
    if (activeElement === this.iframes[i].element) { // user is in this Iframe
    this.iframes[i].cb.apply(window, []);
    var btn = document.getElementById("btn")
    btn.focus()
    }
    }
    }
    }
    };
    IframeOnClick.track(document.getElementById("iFrame"), function () {
    console.log(11111);
    });

    </script>
    </html>

  • 相关阅读:
    HTML <input> 标签
    HTML5 <input> type 属性
    静态页面与动态页面
    string::size_type 页73 size_t 页90
    template method(模板方法)
    C++中创建对象的时候加括号和不加括号的区别(转)
    _declspec(dllexport)和.def(转)
    智能指针
    C++中的delete加深认识
    工厂方法(整理自李建忠<C++设计模式>视频)
  • 原文地址:https://www.cnblogs.com/MagicZhao123/p/7053938.html
Copyright © 2020-2023  润新知