提示:您可以先修改部分代码再运行
浏览器版本 |
4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2) |
a=navigator.appVersion.split(";") //以";"号分割上面的字符串
a {...} Object
[0] "4.0 (compatible" String
[1] " MSIE 7.0" String
[2] " Windows NT 5.1" String
[3] " .NET CLR 2.0.50727" String
[4] " .NET CLR 3.0.04506.30" String
[5] " .NET CLR 3.0.04506.648" String
[6] " .NET CLR 3.5.21022" String
[7] " .NET CLR 3.0.4506.2152" String
[8] " .NET CLR 3.5.30729" String
[9] " InfoPath.2)" String
b=a[1].split(" ")//分割a[1]数组第二字符串
b {...} Object
[0] "" String
[1] "MSIE" String
[2] "7.0" String
return b[2] // 返回IE 版本号"7.0"
关于IE打印的问题,由于IE6不支持全屏打印,如果你的窗口时满屏 ,会打印不全。IE7和IE8都支持全屏打印,所以针对IE打印我们要分开处理。
<script type="text/javascript">
if (document.getElementById('PrintA4')) {
if (isIE() == 6.0) {
document.getElementById('PrintA4').src = document.URL + "&PageSize=A4" + "&IEType=6.0";
}
else {
document.getElementById('PrintA4').src = document.URL + "&PageSize=A4" + "&IEType=7.0";
}
document.getElementById('PrintA3').src = document.URL + "&PageSize=A3";
}
</script>
我们后台根据获取到的pUrl,在后台再次分割字符串,对IE6和Ie7进行处理就行了。
string pUrl = Request.RawUrl;//获取传来的参数
<script type="text/javascript" language="javascript">
function copyCode(obj) {
var rng = document.body.createTextRange();
rng.moveToElementText(obj);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
}
function runCode(obj) {
var winname = window.open('', "_blank", '');
winname.document.open('text/html', 'replace');
winname.document.writeln(obj.value);
winname.document.close();
}
function saveCode(obj) {
var winname = window.open('', '_blank', 'top=10000');
winname.document.open('text/html', 'replace');
winname.document.writeln(obj.value);
winname.document.execCommand('saveas','','code.htm');
winname.close();
}
</script>