Ich habe ein Problem mit einer Inaktivitätsprüfung für meine Website. Ich habe ein Codebeispiel unter StackOverflow gefunden, um eine einfache Inaktivitätsüberprüfung durchzuführen. Und das funktioniertInaktivitätsprüfung in Typoskript
var inactivityTime = function() {
var t;
window.onload = resetTimer;
document.onmousemove = resetTimer;
document.onkeypress = resetTimer;
function logout() {
location.href = 'logout.aspx'
}
function resetTimer() {
clearTimeout(t);
\t \t t = setTimeout(logout, 1000 * 60 * 1);
}
};
Da ich Typoskript mache ich den Code in eine Klasse neu geschrieben. Die Inaktivitätsprüfung funktioniert. es navigiert zu einer anderen Seite. Das Problem, das ich habe, ist, dass es auch zur anderen Seite navigiert, wenn es Aktivität gibt. Ich debuggte den Code und der Cleartimeout-Code wird aufgerufen, aber irgendwie wird es immer noch ausgeführt. Weiß jemand, was ich falsch mache? ist dies die Klasse I in Typoskript gemacht (v1.7)
class Inactivity {
\t private timerHandle: number = null;
\t constructor() {
\t }
\t startChecking() {
\t \t this.resetTimer();
\t \t window.onload = this.resetTimer;
\t \t document.onmousemove = this.resetTimer;
\t \t document.onkeypress = this.resetTimer;
\t }
\t stopChecking() {
\t \t if (this.timerHandle) {
\t \t \t clearTimeout(this.timerHandle);
\t \t \t this.timerHandle = null;
\t \t }
\t }
\t private resetTimer() {
\t \t if (this.timerHandle) {
\t \t \t clearTimeout(this.timerHandle);
\t \t \t this.timerHandle = null;
\t \t }
\t \t this.timerHandle = setTimeout(this.logout, 1000 * 60 * 1);
\t }
\t private logout() {
\t \t location.href = 'logout.aspx';
\t }
}
und das ist, wo ich es nennen:
module Home {
\t var inactivity: Inactivity;
export function init() {
//inactivityTime(); //javascript code that works
inactivity = new Inactivity();
inactivity.startChecking();
}
}
Wo wird die Funktion init() aufgerufen? Es kann mehrere Male aufgerufen werden und Sie können mit mehreren verschiedenen Instanzen von Inaktivität enden. –
wird von der HTML-Seite aufgerufen –