jQuery does not fire when changing the anchor link in the URL... How can I capture this event? -
i have page accordeon-type subsections toggled open clicking on section title or clicking link dropdown in global site navigation.
the intention make sections within page accessible directly anywhere.
the global menu has links in format of
/pagename.aspx#anchor-name /pagename.aspx#anchor-name2
to capture clicks via global navigation, use
var anchor = window.location.hash; if (anchor) { toggle_element(anchor_name); }
within
$(document).ready
unfortunately .ready
fires first time page loaded.
if navigate click on /pagename.aspx#anchor-name
, script runs. if click on /pagename.aspx#anchor-name2
, nothing happens.
how can capture activity?
you need listen hash-change event jquery plugin http://benalman.com/projects/jquery-hashchange-plugin/
Comments
Post a Comment