1. Using AJAX - UpdateProgress Extender that displays a wait modal popup extender when the page is getting loaded and ready
We are going to see the second approach at work -
function doWait()Notice the events onbeforeunload() and onunload() events. The reason we use two events is that these events are browser dependent and so to behave well with different browsers, we do this!
document.body.style.cursor = 'wait';
<body onbeforeunload="doWait();" onunload="doWait();">
Both Mozilla FireFox and Internet Explorer implements onbeforeunload() DOM events.
Another useful function of onbeforeunload() is to alert the user when he leaves the webpage. Read here to know more about this DOM event.