-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Description
I follow this
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="history.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
// we get a normal Location object
/*
* Note, this is the only difference when using this library,
* because the object window.location cannot be overriden,
* so library the returns generated "location" object within
* an object window.history, so get it out of "history.location".
* For browsers supporting "history.pushState" get generated
* object "location" with the usual "window.location".
*/
var location = window.history.location || window.location;
// looking for all the links and hang on the event, all references in this document
$(document).on('click', 'a.ajax', function() {
// keep the link in the browser history
history.pushState(null, null, this.href);
// here can cause data loading, etc.
// do not give a default action
return false;
});
// hang on popstate event triggered by pressing back/forward in browser
$(window).on('popstate', function(e) {
// here can cause data loading, etc.
// just post
alert("We returned to the page with a link: " + location.href);
});
});
</script>
</head>
<body>
<a class="ajax" href="/mylink.html">My Link</a>
<a class="ajax" href="/otherlink.html">Other Link</a>
</body>
</html>
But the Titles are not change when click browser back button.
Metadata
Metadata
Assignees
Labels
No labels