jquery idletimeout和store.js跨多个浏览器标签

时间:2017-04-29 05:01:11

标签: jquery asp.net-mvc

我在MVC 5应用程序中使用了jquery idletimeoutstore.js插件。 我尝试了很多,但仍然无法运行这个例子。 如何使用store.js

我假设Store.js似乎是为Node.js制作的? 我如何在MVC 5中使用这两个插件。

我尝试过的代码如下:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js" type="text/javascript"></script>
<script src="~/Content/app/FrontEnd/js/json.js"></script>
<script src="~/Content/app/FrontEnd/js/require.js"></script>
<script src="~/Content/app/FrontEnd/js/store.js"></script>
<script src="~/Content/app/FrontEnd/js/jquery-idleTimeout.min.js"></script>` $(document).ready(function () {      
        //var engine = require('../src/store-engine')
        //var store = localStorage;
        //if (store.se) {
        //    store.set('idleTimerLoggedOut', true);
        //} else {
        //    alert('Dependent file missing. Please see: https://github.com/marcuswestin/store.js');
        //} 

        $(document).idleTimeout({
            redirectUrl: '/logout',      // redirect to this url on logout. Set to "redirectUrl: false" to disable redirect

            // idle settings
            idleTimeLimit: 1200,           // 'No activity' time limit in seconds. 1200 = 20 Minutes
            idleCheckHeartbeat: 2,       // Frequency to check for idle timeouts in seconds

            // optional custom callback to perform before logout
            customCallback: false,       // set to false for no customCallback
            // customCallback:    function () {    // define optional custom js function
            // perform custom action before logout
            // },

            // configure which activity events to detect
            // http://www.quirksmode.org/dom/events/
            // https://developer.mozilla.org/en-US/docs/Web/Reference/Events
            activityEvents: 'click keypress scroll wheel mousewheel mousemove', // separate each event with a space

            // warning dialog box configuration
            enableDialog: true,           // set to false for logout without warning dialog
            dialogDisplayLimit: 20,       // 20 seconds for testing. Time to display the warning dialog before logout (and optional callback) in seconds. 180 = 3 Minutes
            dialogTitle: 'Session Expiration Warning', // also displays on browser title bar
            dialogText: 'Because you have been inactive, your session is about to expire.',
            dialogTimeRemaining: 'Time remaining',
            dialogStayLoggedInButton: 'Stay Logged In',
            dialogLogOutNowButton: 'Log Out Now',

            // error message if https://github.com/marcuswestin/store.js not enabled
            errorAlertMessage: 'Please disable "Private Mode", or upgrade to a modern browser. Or perhaps a dependent file missing. Please see: https://github.com/marcuswestin/store.js',

            // server-side session keep-alive timer
            sessionKeepAliveTimer: 600,   // ping the server at this interval in seconds. 600 = 10 Minutes. Set to false to disable pings
            sessionKeepAliveUrl: window.location.href // set URL to ping - does not apply if sessionKeepAliveTimer: false
        });
    });`

我收到以下错误消息:

请禁用&#34;私密模式&#34;,或升级到现代浏览器。或者可能缺少一个依赖文件。请参阅:https://github.com/marcuswestin/store.js

1 个答案:

答案 0 :(得分:0)

看起来你错过了依赖。尝试下载jquery.min.js和jqueryui.min.js,并将它们作为您要附加的其他脚本添加到您的类中。

示例:

    <link type="text/css" rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
    <script src="~/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="~/Scripts/jquery-ui-1.8.24.min.js" type="text/javascript"></script>
    <script src="~/Scripts/store.everything.min.js" type="text/javascript"></script>
    <script src="~/Scripts/jquery-idleTimeout.min.js" type="text/javascript"></script>
相关问题