2

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

我正在使用“ https://github.com/ehynds/jquery-idle-timeout ”中的 sessionTimeOut 插件,并在 Lightbox 和 Popup 打开的主页(父窗口)上实现,它在“主”页面上工作正常. 但即使我正在处理 Lightbox 或 Popup 窗口,主窗口会话也会过期。

您能否建议我应该怎么做,即使我正在处理子窗口 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'
    });
});

如果您需要任何其他细节,请告诉我。

请建议

4

0 回答 0