1. General Page
function Checkuserfun () { var maxtime = 2*60*60;//Seconds (2 hours) var time = maxtime; $ (' body '). On (' KeyDown mousemove mousedown Click Scroll ', function (e) {Time = maxtime;//Reset }); var intervalid = setinterval (function () { time--; < = 0 ) { showinvalidloginmessage (); Clearinterval (Intervalid); } },1000) function showinvalidloginmessage () {
Clear User Information alert (' invalid page, please login again '); Jump to login page }}
2. The page with the IFRAME embedded
var maxtime = 2*60*60;//Secondsvar time = Maxtime;function Checkuserfun () {$ (' body '). On (' KeyDown MouseMove Mousedow n Click Scroll ', function (e) {time = MaxTime;//reset}); $ ($ (' #ifr ') [0].contentwindow]. On (' Click Scroll keydown mousemove mousedown ', function (e) {time = MaxTime;//Reset Load (); }); var intervalid = setinterval (function () {time--; if ( time<= 0) {showinvalidloginmessage (); Clearinterval (Intervalid); }},1000) function Showinvalidloginmessage () {Delcookie (' username '); Location.href= ' login.html '; }}function Load () {$ ($ (' #ifr ') [0].contentwindow). On (' Click Scroll keydown mousemove mousedown ', function (e) {time = MaxTime;//reset}); time= MaxTime;//Reset}
Html
<id= "IFR" src= "banner/bannerlist.html" frameborder = "0" width = "100%" Height = "100%" = "load ()"></iframe>
User Stay site No operation, a certain time after the automatic exit