Closed andrewskaggs closed 11 years ago
Hi,
You can specify the version of FireFox and what exactly you do, please give an example
Thanks
Please take a look at this example. Running it in Firefox 17 produces a string without any URL encoding in the address bar. IE 9 and Chrome 23 seem to work fine.
<!DOCTYPE html>
<html>
<body>
<a id="demolink" href="">Click Me</a>
</body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
<script src="history.js"></script>
<script type="text/javascript">
$("#demolink").click(function(event) {
var objectToSerialize = { var1: "foo", var2: "bar" };
var queryString = "?data=" + escape(JSON.stringify(objectToSerialize));
history.pushState(null,null,queryString);
event.preventDefault();
});
</script>
</html>
Hi,
method escape
is deprecated and non standart, use encodeURIComponent
method, that encode all symbols, if it does not lead to any results, write me about it and I will solve this bug.
Thanks
encodeURIComponent
fixed the demo I posted above but was not sufficient for the application I'm working on. I will try to come up with a more complete demo to show you. Thanks for replying!
I traced through what is actually going on and discovered that this is a Firefox issue with partially decoding the URI for display. The HTML5-History-API works perfectly after using encodeURIComponent
. Thanks for the great work - I will definitely be using this project!
I am attempting to call history.pushState with a URL that contains escaped JSON data but the behavior is not correct in Firefox. The URL written to the address bar has some escaping removed and no longer works when pasted into a new browser. The problem does not occur in Chrome or IE 9.
history.pushState input URL:
Firefox address bar result:
IE9 address bar result:
Chrome address bar result: