Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What are the best scripts to prevent user to redirect or refresh or press back button on a web page?

<p>want to <strong>prevent</strong> a logged user from pressing <strong>back button</strong> or <strong>reload</strong> the page or not to <strong>redirect</strong> any way from the existing page. May user's logging session will expire if he try to do any one of above circumstances.</p>

user-image
Question ajoutée par Suman Rajbhar , System Analyst , Sys Dev Limited
Date de publication: 2014/10/29

Use this on window on load event:

<body onunload="javascript:history.go(1)">

 

use jQuery to prevent page refresh .

function disableF5(e) { if ((e.which || e.keyCode) ==116) e.preventDefault(); };

// To disable f5

    /* jQuery <1.7 */

$(document).bind("keydown", disableF5);

/* OR jQuery >=1.7 */

$(document).on("keydown", disableF5);

 

// To re-enable f5

    /* jQuery <1.7 */

$(document).unbind("keydown", disableF5);

/* OR jQuery >=1.7 */

$(document).off("keydown", disableF5);

 

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?