Closed jonagoldman closed 10 years ago
Probably this?
/*
* Note, this is the only difference when using this library,
* because the object document.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 "document.location".
*/
var returnLocation = history.location || document.location;
This is not a bug. This is correct operation history.location
in non-HTML5 browsers
So if I understand correctly the next line alone is not enough, and can something lead to undesired behavior:
var returnLocation = history.location || document.location;
and I need to use Modernizr or similar to detect the real browser capabilities, something like:
var returnLocation = document.location;
if (Modernizr.history) {
returnLocation = history.location;
}
or without Modernizr:
var returnLocation = document.location;
if (window.history && window.history.pushState) {
returnLocation = history.location;
}
Right?
Enough to use:
var returnLocation = history.location || document.location;
I write in their projects as follows:
(function() {
var location = history.location || document.location;
// ...
// ... // other code
// ...
console.log(location.href);
// ...
// ... // other code
// ...
})();
But if I use it like that then in IE9 history.location.href is incorrect and different from other browsers, but I want the same behavior for all.
I understand you. You want the impossible. But, IE9 has no support for HTML5-History-API, for this reason this library emulates this feature.
If your site is located in the root folder: /he/project/2/
. To do this you need to add the directive basepath
with a value /he/project/2/
.
for example:
<script src="history.js?basepath=/he/project/2/"></script>
or
<script src="history.js"></script>
<script>
history.redirect(null, '/he/project/2/');
</script>
Oh, I will try that. Thanks!
I close this issue, if you still want to solve this, let me know. Thank you
Hi, In IE9, the history.location.href is incorrect, but document.location.href is correct, as you can see in the next image:
This always happens whit the first page we browse to, so I think this is because the first page we enter is not saved correctly in the history state.
Any idea how to fix this? Thanks, and great script by the way!