我試圖解決這個問題,我用jQuery LavaLamp的菜單欄在我的網站中加入下面的代碼串由驚人的發展,人們在這個社會一個建議面臨的問題:爲什麼我在網站上看到這個錯誤?
<script>
if ($.browser.version < 9.0 && $.browser.msie) {
document.getElementsByTagName("head")[0].innerHTML = '<script type="text/javascript" src="./Scripts/jquery.easing.1.1.js"></script><script type="text/javascript" src="./Scripts/jquery.preloader.js"></script><script type="text/javascript" src="./Scripts/jquery.lavalamp.js"></script><script type="text/javascript" src="./Scripts/lavalamp-config.js"></script>';
}
else {
document.getElementById("head")[0].innerHTML = '<script type="text/javascript" src="./Scripts/jquery.easing.1.1.js"></script><script type="text/javascript" src="./Scripts/jquery.preloader.js">';
}
</script>
而且在在Visual Studio 2010中,我得到了以下錯誤
Unterminated string constant
以下行下:
document.getElementsByTagName("head")[0].innerHTML = '<script type="text/javascript" src="./Scripts/jquery.easing.1.1.js"></script><script type="text/javascript" src="./Scripts/jquery.preloader.js"></script><script type="text/javascript" src="./Scripts/jquery.lavalamp.js"></script><script type="text/javascript" src="./Scripts/lavalamp-config.js"></script>';
那麼我該如何解決這個問題?
更新#1:
我我的代碼更新到你的建議是什麼傢伙,我仍然得到同樣的錯誤。此外,這裏的錯誤的快照:
更新#2 我修改代碼來讓母版頁包含下面的代碼,我仍然獲得,顯示在頂部同樣的錯誤如上面的快照中所示。
<head>
<script type="text/javascript">
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer') {
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat(RegExp.$1);
}
return rv;
}
</script>
<script type="text/javascript">
if (getInternetExplorerVersion() < 9.0 && browser_type = "Microsoft Internet Explorer") {
document.getElementsByTagName("head")[0].innerHTML = "<script type='text/javascript' src='./Scripts/jquery.easing.1.1.js'></script><script type='text/javascript' src='./Scripts/jquery.preloader.js'></script><script type='text/javascript' src='./Scripts/jquery.lavalamp.js'></script><script type='text/javascript' src='./Scripts/lavalamp-config.js'></script>";
} else {
document.getElementById("head")[0].innerHTML = "<script type='text/javascript' src='./Scripts/jquery.easing.1.1.js'></script><script type='text/javascript' src='./Scripts/jquery.preloader.js'>";
}
</script>
</head>
您知道'$ .browser'即將被棄用。看看'$ .support'。 – elclanrs 2012-08-14 04:27:09