Reputation: 1093
If I go to a page with a hash tag, e.g http://www.wired.com/#spack4, I notice that the page loads and then jumps down to the id spack4
. I'd like to attach a Javascript function for when it jumps down. Is there a DOM event that triggers this?
Upvotes: 0
Views: 1138
Reputation: 754
What are you trying to do?
Maybe you could use the window.pageYoffset
property to check if the document is or is not at the top:
function isTopOfPage() {
var yPosition = window.pageYOffset;
if(yPosition == 0) {
//top of page
return true;
}
else if(yPosition > 0) {
// not at the top of the page
return false;
}
}
You can then call this function onload.
Upvotes: 1