ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل Suman Rajbhar , System Analyst , Sys Dev Limited
تاريخ النشر: 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);

 

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟