0

I am accessing a web page and I am trying to write a jQuery script to detect whenever the page loads a new content. The problem is, When the page first loads it throws an on('load') event, but every subsequent navigation seems to be within the page and I cannot figure out how to catch those.

This is what I did. Navigate to the below link. Open up Google Chrome devtools console. Try to add a jQuery event listener as below.

$(document).on('click',function(){console.log("click");})

This works for all the clicks. I tried the load, reload, change event, but that does not work all the time. How do I catch an event when the user navigates to another "page" (or section) within this demo site.

http://www.emc.com/microsites/vipr-demo/index.htm#/vdc/1/admin/dashboard/admin-dashboard

Sudharsan S
  • 15,336
  • 3
  • 31
  • 49
mumshad
  • 409
  • 1
  • 7
  • 13

1 Answers1

0

Since your url gets changed when a different section of the web page gets loaded, you can use hashchange event.

See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onhashchange and On - window.location.hash - Change?

Community
  • 1
  • 1
Nipuna
  • 6,846
  • 9
  • 64
  • 87
  • Tried this doesnt seem to work:$(window).on('hashchange', function() {console.log("hasChange");}); – mumshad Jul 13 '15 at 09:42