要有<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">才能获取到document.documentMode,可问题是<!DOCTYPE...>不在第一句,第一句被后台框架输出了一个JS脚本C#的。真不知道怎么解决了,把!DOCTYPE加到JS前面整个页面就乱了...,获取不到document.documentMode JQgrid就用不了,愁死了
<div id='divLoading' style='position:absolute;'>
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
if (document.documentMode !== undefined) { // IE only
alert(document.documentMode);
return;
}
})
</script>
</head>
<body>
</body>
</html>
<div id='divLoading' style='position:absolute;'>
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
if (document.documentMode !== undefined) { // IE only
alert(document.documentMode);
return;
}
})
</script>
</head>
<body>
</body>
</html>
<div id='divLoading' style='position: absolute;'>divLoading</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#divLoading").remove();
if (document.documentMode !== undefined) { // IE only
alert(document.documentMode);
return;
}else{
alert("没搞定!");
}
});
</script>
</head>
<body>
</body>
</html>
试了一下, 把这个元素移走, 在IE8中可以, 但IE6/IE7都不行。 其实要解决也并不困难, 问题出在后台框架上, 那么让后台框架把
<div id='divLoading' style='position:absolute;'>
</div>
放在页面的尾部不就得了!
或者设置一个开关, 有的页面允许不添加这个div