History.js not working in Internet Explorer
Asked Answered
F

1

7

I am trying to get history.js to work in Internet Explorer because I need history.pushState() to work. I have read over the instructions on GitHub (https://github.com/browserstate/History.js/) and have tried implementing it, but havent had any success. Here's what I have

<!DOCTYPE html>
<html>
<head>
    <!-- jQuery --> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> 
    <!-- History.js --> 
    <script defer src="http://balupton.github.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script> 
    <script type="text/javascript">
        function addHistory(){

            // Prepare
            var History = window.History; // Note: We are using a capital H instead of a lower h

            // Change our States
            History.pushState(null, null, "mylink.html"); 
        }      
    </script>
</head>
<body>
    <a href="mylink.html">My Link</a>
    <a href="otherlink.html">Other Link</a>
    <button onclick="addHistory()" type="button">Add History</button>   
</body>

Not sure what I'm doing wrong, but it's definitely not working in IE8 or IE9. It does work in Firefox, but that may be because Firefox actually supports history.pushstate to begin with. Any help is appreciated

Feu answered 5/7, 2012 at 21:13 Comment(4)
Is it working anywhere else, or have you only tried IE?Splitlevel
Every version of IE or what version(s) have you tried?Herve
I have tried IE8 and IE9, sorry for leaving that out. It works in Firefox but that might be because it supports history.pushstate by default?Feu
What exactly are you expecting it to do? History.js should work in most browsers, even IE, but the way it works is different in HTML4 and HTML5 compatible browsers.Exhibition
I
1

In second <script> tag remove the word defer.
because, if you mention that word, which means postpone. ( If you want to save that from to reduce blocking of page rendering, don't remove it). That too IE is very strict, that's why you got that problem. Hope it helps

refer this

Innocent answered 8/5, 2013 at 10:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.