HTML用JS识别浏览器,IE内核则调用谷歌打开指定链接

1,388 阅读2分钟

HTML用JS识别浏览器,IE内核则调用谷歌打开指定链接


日期 指导人 内容描述
2020年04月 赵X 本意做统一身份认证单点登录平台,后只做超链接

文本显示调整

©2020 by cxj
改变字体、颜色、大小、居中


© 2020 by cxj         
改变字体、颜色、大小、右对齐(左对齐用left)


整理一些特殊符号
特殊字符 描述 字符的代码
空格符  
< 小于号 &lt;
> 大于号 &gt;
& 和号 &amp;
人民币 &yen;
© 版权 &copy;
® 注册商标 &reg;
°C 摄氏度 &deg;C
± 正负号 &plusmn;
× 乘号 &times;
÷ 除号 &divide;
² 平方(上标²) &sup2;
³ 立方(上标³) &sup3;
编辑html文件如下内容
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>index</title>
</head>
<body>
<script type="text/javascript">
function test() {
	/*
	创建ActiveXObject实例,只在IE下有效,才可以创建
	*/
	if (IEVersion() != -1 ){
		var objShell= new ActiveXObject("WScript.Shell");
		/*
		命令参数说明
		cmd.exe /c dir 是执行完dir命令后关闭命令窗口。
		cmd.exe /k dir 是执行完dir命令后不关闭命令窗口。
		cmd.exe /c start dir 会打开一个新窗口后执行dir指令,原窗口会关闭。
		cmd.exe /k start dir 会打开一个新窗口后执行dir指令,原窗口不会关闭。
		这里的dir是start chrome www.baidu.com//用谷歌浏览器打开百度
		*/
		objShell.Run("cmd.exe /c start chrome http://10.x.x.x",0,true);
		window.opener=null;
		window.open('','_self');
		window.close();
	} else{
	 window.open("http://10.x.x.x");
	}
}
function IEVersion() {
            var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
            var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
            var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
            var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
            if(isIE) {
                var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
                reIE.test(userAgent);
                var fIEVersion = parseFloat(RegExp["$1"]);
                if(fIEVersion == 7) {
                    return 7;
                } else if(fIEVersion == 8) {
                    return 8;
                } else if(fIEVersion == 9) {
                    return 9;
                } else if(fIEVersion == 10) {
                    return 10;
                } else {
                    return 6;//IE版本<=7
                }
            } else if(isEdge) {
                return 'edge';//edge
            } else if(isIE11) {
                return 11; //IE11
            }else{
                return -1;//不是ie浏览器
            }
        }
</script>
<body onload="test()">
</body>
</html>

其实就上面这段是有用的。