【问题标题】:Body Load HTML with iframe使用 iframe 加载 HTML
【发布时间】:2018-09-04 11:47:12
【问题描述】:

嗨,这是我的 hmtl 和 JS 到目前为止,我希望它也能检测 iframe 窗口中的鼠标移动、滚动和箭头,因为大多数网站都在 iframe 中,所以我在其他地方寻找过所有似乎都过分的地方检测运动很复杂。

任何帮助将不胜感激 谢谢你

<script type="text/javascript">
        // Set timeout variables.
        var timoutWarning = 1000; // Display warning in 1Mins.
        var timoutNow = 2000; // Timeout in 2 mins.

        var warningTimer;
        var timeoutTimer;

        // Start timers.
        function StartTimers() {
            warningTimer = setTimeout("IdleWarning()", timoutWarning);
            timeoutTimer = setTimeout("IdleTimeout()", timoutNow);
        }

        // Reset timers.
        function ResetTimers() {
            clearTimeout(warningTimer);
            clearTimeout(timeoutTimer);
            StartTimers();
            $("#timeout").dialog('close');
        }

        // Show idle timeout warning dialog.
        function IdleWarning() {
            var answer = confirm("Session About To Timeout\n\n       You will be automatically logged out.\n       Confirm to remain logged in.")
                if (answer){

                    ResetTimers();
                }
                else{
                    IdleTimeout();
                }
        }       

        // Logout the user and auto reload or use this window.open('http://www.YourPageAdress.com', '_self'); to auto load a page.
        function IdleTimeout() {
            window.open(self.location,'_top');
        }
    </script>

    <body onload="StartTimers();" onmousemove="ResetTimers();" onKeyPress="ResetTimers();"

【问题讨论】:

  • 每个框架都有自己的窗口,事件发生在该窗口内,不会冒泡到框架的父级。因此,您还需要能够监听这些框架内的移动并与首页协调

标签: javascript html iframe timeout


【解决方案1】:

类似 *

$(".in").on("mouseover",function(){
   $(this).css("background","blue");
});
$(".in").on("mouseout",function(){
   $(this).css("background","green");
});
.in{width:50px;height:50px;background:red;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="in"></div>
  • 并像这样使用多个$("selector").on("mouseover mouseout mousemove",function(){ call back });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多