I have downloaded the zip from https://github.com/browserstate/history.js and then uploaded the browserstate-history.js-e84ad00\scripts\uncompressed\history.js in my web application. I am using an html to test this. Following is the script kept in the html.
<script type="text/javascript">
var count=0;
$(document).ready(function(){
$("#change").click(function(){
count=count+1;
$.ajax({
url: "fetch.html",
cache: false,
dataType: "html",
success: function(responseHTML){
wrappedResponseHTML = "<div id='responseTextWrapperDiv'>" + responseHTML + "</div>";
$("#data").html(($(wrappedResponseHTML).find("#toggle")).html());
history.pushState(document.getElementById("data").innerHTML, "", "?page="+count,"");
}
});
});
$("#change2").click(function(){
count=count+1;
$.ajax({
url: "fetch2.html",
cache: false,
dataType: "html",
success: function(responseHTML){
wrappedResponseHTML = "<div id='responseTextWrapperDiv'>" + responseHTML + "</div>";
$("#data").html(($(wrappedResponseHTML).find("#toggle")).html());
history.pushState(document.getElementById("data").innerHTML, "", "?page="+count,"");
}
});
});
});
window.onpopstate = function(event) {
document.getElementById('data').innerHTML=event.state;
if(event.state==null)
{
window.location.href=window.location.href;
}
};</script>
Here goes the body part:
<body>
<div id="data">
Landing Page
</div>
<div>
<input type="button" id="change" value="change text" />
<input type="button" id="change2" value="change text 2" />
</div>
<div>
<input type="button" id="back" value="go back" onclick="history.go(-1);"/>
</div></body>
The text inside div with id "data" is changed using ajax. This works fine in Mozilla 15.0.1 but when I tested it in IE 8, the history functionality is not working and I am not going back to the previous state. Instead, I am going back to the previous page which called my html. In one of the forums, the suggested solution was to include History.js, which I have included. Is there anything else that I am missing out?