- All same domain links without a target attribute will use the History API where available
- Instead of requesting the link
HREF
, an ajax call will be made to the same endpoint with a get parameter ofajax=true
appended. - The contents of this request will be put into an area with ID
main
- If a navigation bar with an ID of
site-nav
is found, any element within it with an ID matching the first level of the URL path, prepended bysite-nav-
will have the classactive
added to it. For example a link to/page1/some-sub-page/
will result in the link with ID#site-nav-page1
having a classactive
added. - The first
H1
within the requested content will be used for the page title.
joshje / history-ajax Goto Github PK
View Code? Open in Web Editor NEWNavigate same site links using the HTML5 History API and AJAX
Home Page: http://history-ajax.joshemerson.co.uk