when user click on goback broswer page will come , at forward clicks login page should come

Discussão em 'Angular' iniciado por Monika, Março 10, 2025.

  1. Monika

    Monika Guest

    ngOnInit(){ window.addEventListener("popstate", (event) => { console.log("Navigation event:", event); if (!document.referrer.includes("wiyour text`ndow.location.origin")) { // If user leaves the site, mark them as "left" sessionStorage.setItem("userLeft", "true");

    }
    });
    setTimeout(() => {
    if (sessionStorage.getItem("userLeft")) {
    console.log("User returned via forward button, logging out...");
    this.router.navigate(["/auth/login"]);
    }
    }, 100); }`

    Continue reading...

Compartilhe esta Página