javascript - alert on back button click in a php project -


i working on online quiz system php , mysql displays 1 question @ time , question submitted displays second 1 , on. want prevent student student leaving exam page clicking button or close tab. tried following code:

window.onbeforeunload = function (e) {   var message = "your confirmation message goes here.",   e = e || window.event;   // ie , firefox   if (e) {     e.returnvalue = message;   }  }; 

it alerts student when clicks button or close page gives alert when student submitting first question display second one. have idea how solve problem???

  if (e) {     e.returnvalue = message;   } 

you have validate event. have id submit/next button , try validate event. suppose have id called "submit" submit button

if (e.target.id !== 'submit') {     e.returnvalue = message;   } 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -