Javascript window events


Onbeforeunload function in javascript

When you have filled up a form in a web page and if you  close the page before submitting it

You may get a message " Are you sure to leave this page?" Such customized messages are examples of window events onbeforeunload


onbeforeunload event is fired when the document unloads its resources. You may notice the document is still visible and the event can be cancelled. onbeforeunload event is assigned to the <body> element.

Various mobile user agents ignore the event.



Subscribe to Creative Technocrayts and be a part of growing community.


HTML code:

<body onbeforeunload="return myFunction()">
Other tags
</body>

SCRIPT code:

function myFunction(){
  return "Your message goes here"
}


UI practice series

DOM manipulation using jQuery

Input range slider UI and populating the value

DOM functions and array


Feel free to share your feedback / queries and  Subscribe to Creative Technocrayts and be a part of growing community.
Fb link : @CreativeTechnocrayts

Comments

Popular posts from this blog

What are some mistakes people make when they start learning HTML, CSS and JavaScript?

How to initialize Datatable plugin?

Datatables.net - Plugin options