admin管理员组文章数量:1335371
Anybody knows why window.location is undefined in ie8 (maybe ie7 too), but works as document.location?
I couldn't find why another file, from other project has a similar code but hasn't a problem with IE.
I'm get a weird error too: 'window.location.hash is null or not an object in jquery 1.6.4 line 2'. I tried 1.5.1 too, but same error.
The header:
<html lang="">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="assets/css/style.css">
<script src="assets/js/jquery.1.6.4.min.js"></script>
<!--[if lt IE 9]>
<script src=".js"></script>
<![endif]-->
<script src="assets/js/jquery.easing.1.3.js"></script>
<script src="assets/js/jquery.ba-hashchange.min.js"></script>
<script src="assets/js/script.js"></script>
</head>
The JS part:
if( window.onhashchange )
{
window.onhashchange = function()
{
hashChanged( window.location.hash );
}
}
else
{
var storedHash = window.location.hash;
window.setInterval( function()
{
if( window.location.hash != storedHash )
{
storedHash = window.location.hash;
hashChanged( storedHash );
}
}, 100 );
}
Anybody knows why window.location is undefined in ie8 (maybe ie7 too), but works as document.location?
I couldn't find why another file, from other project has a similar code but hasn't a problem with IE.
I'm get a weird error too: 'window.location.hash is null or not an object in jquery 1.6.4 line 2'. I tried 1.5.1 too, but same error.
The header:
<html lang="">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="assets/css/style.css">
<script src="assets/js/jquery.1.6.4.min.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode./svn/trunk/html5.js"></script>
<![endif]-->
<script src="assets/js/jquery.easing.1.3.js"></script>
<script src="assets/js/jquery.ba-hashchange.min.js"></script>
<script src="assets/js/script.js"></script>
</head>
The JS part:
if( window.onhashchange )
{
window.onhashchange = function()
{
hashChanged( window.location.hash );
}
}
else
{
var storedHash = window.location.hash;
window.setInterval( function()
{
if( window.location.hash != storedHash )
{
storedHash = window.location.hash;
hashChanged( storedHash );
}
}, 100 );
}
Share
Improve this question
edited Aug 3, 2017 at 16:45
MrBoJangles
12.2k17 gold badges64 silver badges82 bronze badges
asked Oct 17, 2011 at 16:57
Ratata TataRatata Tata
2,8791 gold badge37 silver badges49 bronze badges
3
-
3
Are you missing
<!DOCTYPE html>
or did you not paste that? – canon Commented Oct 17, 2011 at 16:59 -
Is it just an issue in IE? Or other browsers too? Do you have any variables named
location
? – user113716 Commented Oct 17, 2011 at 17:07 - Just IE. Was something like this, @Ӫ_._Ӫ – Ratata Tata Commented Oct 17, 2011 at 17:18
1 Answer
Reset to default 6Something in your project may be overriding window.location
, though this won't work in IE 9:
var location;
alert(window.location);
//-> "undefined"
You could use the delete
operator to delete the variable (although technically you shouldn't be able to, but it does work):
delete location;
But the best solution would be to look for the offending piece of code in your file.
本文标签: javascriptwindowlocation is undefined in ie8Stack Overflow
版权声明:本文标题:javascript - window.location is undefined in ie8 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742382160a2464309.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论