21.03.2024, 09:26
(17.03.2018, 13:39)Erwin van der Zwart Wrote: Hi,
No, that would be to easy (:
Add this after line 24:
So result looks like:Code:$(location).attr("href", "/logout");
BR,Code:var SE_Goto_Startpage = No_Usage_Detected(function(e) {
if ( currentPlanId != SE_Startpage ) {
showPlan(SE_Startpage);
$(location).attr("href", "/logout");
}
}, SE_Timeout);
Erwin
Hi Erwin,
I've modified your example to a version that only does the logout part without the goto startpage part as you can see in the script below. Only issue is that the iframe part is not working any longer and i can't figure out how to solve this. Do you have any idea?
Code:
$(function() {
// Logout after x seconds (in miliseconds)
var SE_Timeout = 90000; // adjust this timer value if needed (90 seconds in miliseconds)
var eventlist = 'vclick vmousedown vmouseout touchend';
// Timer function no usage detected
function No_Usage_Detected(callback, timeout, _this) {
var timer;
return function(e) {
var _that = this;
if (timer)
clearTimeout(timer);
timer = setTimeout(function() {
callback.call(_this || _that, e);
}, timeout);
}
}
// Logout when timer elapsed
var SE_Goto_Login = No_Usage_Detected(function(e) {
$(location).attr("href", "/logout");
}, SE_Timeout);
// Add event listener to document to detect user input
$(document).on(eventlist, function() {
SE_Goto_Login();
});
// Add event listener to all iframes to detect user input inside iframes
$('iframe').load(function() {
var iframe = $('iframe').contents().find('html');
iframe.on(eventlist, function(event) {
SE_Goto_Login();
});
});
});