Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 正在更新会话超时的子窗口(弹出窗口或Lighbox)和父窗口事件_Javascript_Jquery_Jquery Ui_Session_Session Timeout - Fatal编程技术网

Javascript 正在更新会话超时的子窗口(弹出窗口或Lighbox)和父窗口事件

Javascript 正在更新会话超时的子窗口(弹出窗口或Lighbox)和父窗口事件,javascript,jquery,jquery-ui,session,session-timeout,Javascript,Jquery,Jquery Ui,Session,Session Timeout,我想实现“sessionTimeout”功能,因此,即使用户打开了辅助窗口或灯箱,用户也应该获得sessionTimeout弹出窗口,并且根据用户的响应,父窗口和子窗口都应该获得sessionTimeout事件通知: 我正在使用来自“”的sessionTimeOut插件,并在主页面(父窗口)上实现,从那里Lightbox和Popup都会打开,它在“主页面”上工作正常。但即使我正在处理Lightbox或弹出窗口,主窗口会话也会过期 您能建议我应该怎么做吗?即使我正在处理子窗口,sessionTim

我想实现“sessionTimeout”功能,因此,即使用户打开了辅助窗口或灯箱,用户也应该获得sessionTimeout弹出窗口,并且根据用户的响应,父窗口和子窗口都应该获得sessionTimeout事件通知:

我正在使用来自“”的sessionTimeOut插件,并在主页面(父窗口)上实现,从那里Lightbox和Popup都会打开,它在“主页面”上工作正常。但即使我正在处理Lightbox或弹出窗口,主窗口会话也会过期

您能建议我应该怎么做吗?即使我正在处理子窗口,sessionTimeout也不应该提示,如果有一段时间不工作,则提示应该出现在子窗口上,并且应该关闭子窗口并注销父窗口

请查找下面提到的代码:

会话到期消息的代码:

<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="~/Scripts/js/jquery.idletimeout.js"></script>
<script src="~/Scripts/js/jquery.idletimer.js"></script>
<body>
    <div id="dialog" title="Your session is about to expire!">
        <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 50px 0;"></span>You will be logged off in <span id="dialog-countdown" style="font-weight: bold"></span>seconds.</p>
        <p>Do you want to continue your session?</p>
    </div>
</body>
<script type="text/javascript">
    // setup the dialog
    $("#dialog").dialog({
        autoOpen: false,
        modal: true,
        width: 400,
        height: 200,
        closeOnEscape: false,
        draggable: false,
        resizable: false,
        buttons: {
            'Yes, Keep Working': function() {
                $(this).dialog('close');
            },
                'No, Logoff': function() {
                // fire whatever the configured onTimeout callback is.
                // using .call(this) keeps the default behavior of "this" being the warning
                // element (the dialog in this case) inside the callback.
                $.idleTimeout.options.onTimeout.call(this);
            }
        }
    });

    // cache a reference to the countdown element so we don't have to query the DOM for it on each ping.
    var $countdown = $("#dialog-countdown");

    // start the idle timer plugin
    $.idleTimeout('#dialog', 'div.ui-dialog-buttonpane button:first', {
        idleAfter: 600,
        pollingInterval: 2,
        serverResponseEquals: 'OK',
        onTimeout: function() {
            window.location = "/Home/Index/";
        },
        onIdle: function() {
            $(this).dialog("open");
        },
        onCountdown: function(counter) {
            $countdown.html(counter); // update the counter
        }
    });
</script>
function basicPopup(url) {
    var popupWindow = window.open(url, 'popUpWindow', 'height=800,width=1350,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no, status=yes');
}
 //Lightbox Function
$(document).ready(function () {
    $(".various").fancybox({
        maxWidth: 1000,
        maxHeight: 800,
        fitToView: false,
        width: '80%',
        height: '80%',
        autoSize: false,
        closeClick: false,
        openEffect: 'none',
        closeEffect: 'none'
    });
});
灯箱代码:

<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css">
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="~/Scripts/js/jquery.idletimeout.js"></script>
<script src="~/Scripts/js/jquery.idletimer.js"></script>
<body>
    <div id="dialog" title="Your session is about to expire!">
        <p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 50px 0;"></span>You will be logged off in <span id="dialog-countdown" style="font-weight: bold"></span>seconds.</p>
        <p>Do you want to continue your session?</p>
    </div>
</body>
<script type="text/javascript">
    // setup the dialog
    $("#dialog").dialog({
        autoOpen: false,
        modal: true,
        width: 400,
        height: 200,
        closeOnEscape: false,
        draggable: false,
        resizable: false,
        buttons: {
            'Yes, Keep Working': function() {
                $(this).dialog('close');
            },
                'No, Logoff': function() {
                // fire whatever the configured onTimeout callback is.
                // using .call(this) keeps the default behavior of "this" being the warning
                // element (the dialog in this case) inside the callback.
                $.idleTimeout.options.onTimeout.call(this);
            }
        }
    });

    // cache a reference to the countdown element so we don't have to query the DOM for it on each ping.
    var $countdown = $("#dialog-countdown");

    // start the idle timer plugin
    $.idleTimeout('#dialog', 'div.ui-dialog-buttonpane button:first', {
        idleAfter: 600,
        pollingInterval: 2,
        serverResponseEquals: 'OK',
        onTimeout: function() {
            window.location = "/Home/Index/";
        },
        onIdle: function() {
            $(this).dialog("open");
        },
        onCountdown: function(counter) {
            $countdown.html(counter); // update the counter
        }
    });
</script>
function basicPopup(url) {
    var popupWindow = window.open(url, 'popUpWindow', 'height=800,width=1350,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no, status=yes');
}
 //Lightbox Function
$(document).ready(function () {
    $(".various").fancybox({
        maxWidth: 1000,
        maxHeight: 800,
        fitToView: false,
        width: '80%',
        height: '80%',
        autoSize: false,
        closeClick: false,
        openEffect: 'none',
        closeEffect: 'none'
    });
});
如果你需要任何其他细节,请告诉我


请建议

仅当URL为home/index/时,此选项才有效?我认为您还需要将其附加到fancybox div
。各种
。是的。。。如果我打开一个弹出窗口或Lighbox,我会收到超时警报,但只有一个主页。。不在Lightbox/Popop页面上…你的意思是说整个函数“$”(“#dialog”)。dialog({”应该在“$”(“.variable”)。fancybox({”和“function basicpoup(url){”??我不这么认为,文档不清楚。我会继续阅读。找到一种方法,一旦启动或弹出该函数,就触发它。将它放入一个函数并调用它。