任何人都知道爲什麼window.location在ie8(也許ie7也是)中未定義,但作爲document.location?window.location在ie8中是未定義的
我找不到爲什麼另一個文件,從其他項目有一個類似的代碼,但沒有與IE瀏覽器的問題。
我也得到一個奇怪的錯誤:'window.location.hash爲空或不是jquery 1.6.4第2行中的對象'。我也試過1.5.1,但同樣的錯誤。
標題:
<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.com/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>
JS部分:
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);
}
你是否缺少'<!DOCTYPE html>'或者你沒有粘貼? – canon
它只是*在IE中的問題?或其他瀏覽器呢?你有沒有名爲'location'的變量? – user113716
只是IE。是這樣的,@Ӫ_._Ӫ –