我正在尝试通过添加以下由该社区中一位出色的开发人员和人员建议的代码来解决我在网站中使用 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 中,出现以下错误
未终止的字符串常量
在以下行下:
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>