Today i'm going to tell you one small and basic javascript snippet for alert confirmation on browser closing time. i recently used whats app web that time before closing my session that asks me confirmation alert navigation. like that more sites are using this kind of confirm navigation on before closing browser tab, and it is mostly coming in form submission time, without filling the full form people trying to close or refreshing tab that time this kind of alert navigation will come. so let see the code for that suing javascript.
Like the above image you may get some where while you surfing any where on internet. that is running by javascript.
JAVASCRIPT
<script> window.onbeforeunload = function (example) { example = example || window.event; // For IE and Firefox prior to version 4 if (example) { example.returnValue = 'Are you sure you want to close the Tab?'; } // For Safari return 'Are you sure you want to close the Tab?'; }; </script>
window.onbeforeload is make this operation, which means that alert comes on that window.onbeforeload function. that returns the value.
RELATED POSTS :
Change background on refresh using Java script
Alert style validation using Javascript
Disable right click and protect your content from coping using Java script
Redirect the page using javascript without .htaccess
Enable right click by disable javascript in browser
Set current time using javascript for websites
Go back to previous and next page onClick in browser using Javascript
not working
ReplyDeleteLive demo link mistake bro change pannunga
ReplyDeleteLive demo link mistake bro change pannunga
ReplyDelete