javascript - Detect if a new page is being loaded -


is there way detect via javascript, whether new page being loaded. let me give example.

another page being loaded after on link:

<a href='http://google.com/'>click here</a> 

there's no page load after click here:

<a href='#anchor'>click here</a> 

no page load here either:

<a href='javascript:void(0);'>click here</a> 

yep, that's page load. href attribute not url of page being loaded:

<a href='javascript:void(document.location="http://google.com/");'>click here</a> 

this has url in href, not load page. onclick attribute here illustrate problem. in real world, onclick event attached event listener , canceled event.preventdefault() somewhere else in code:

<a href='http://google.com/' onclick='return false;'>click here</a> 

now imagine, next page takes long time load. need way detect whether new page being loaded, after click on link. or after form submit. or after action can result in page load. know actions watch, can't sure if trigger page load.

is possible? if so, how?

thanks.

probably beforeunload event looking for. such event handlers used, example, prevent user accidentally leaving page filled form showing confirmation dialog custom text message.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -