How to use eric hynds idle timeout plugin

2019-08-25 21:22发布

I want to use this plugin here which displays a message stating if you want to continue with session or that session would be timed out. Pretty much it is a plug created by eric hynds where if the user does not use the computer for a period amount of time, then it will display a message if user wants to continue or not. If yes then continue, if not then user is timed out.

But anyway my question is that to be able to use this pluging, what files do I need? There is a src folder with 2 js scripts but I don't know id I need one of them or both of them, so I thought of asking people who have used this plugin.

Also if I want to use the plugin for multiple documents then do I just give them different id/class names?

Thanks

2条回答
相关推荐>>
2楼-- · 2019-08-25 21:54

Just take a peak at the demo page's source code:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"
type="text/javascript"></script>
<script src="src/jquery.idletimer.js" type="text/javascript"></script>
<script src="src/jquery.idletimeout.js" type="text/javascript"></script>
<script type="text/javascript">
    $.idleTimeout('#idletimeout', '#idletimeout a', {
        idleAfter: 5,
        pollingInterval: 2,
        keepAliveURL: 'keepalive.php',
        serverResponseEquals: 'OK',
        onTimeout: function () {
            $(this).slideUp();
            window.location = "timeout.htm";
        },
        onIdle: function () {
            $(this).slideDown(); // show the warning bar
        },
        onCountdown: function (counter) {
            $(this).find("span").html(counter); // update the counter
        },
        onResume: function () {
            $(this).slideUp(); // hide the warning bar
        }
    });
</script>
查看更多
趁早两清
3楼-- · 2019-08-25 22:00

You need to add following two scripts in your workspace:

  1. src/jquery.idletimer.js
  2. src/jquery.idletimeout.js

Like here:

<script src="src/jquery.idletimer.js" type="text/javascript"></script>
<script src="src/jquery.idletimeout.js" type="text/javascript"></script>

Download it and add in workspace then create a JSP add above code in JSP and include anywhere you want to display session timeout.

regards, Vaquar Khan

查看更多
登录 后发表回答