方法一:- <script language="javascript">
- function getIE()
- {
- if(navigator.appName == "Microsoft Internet Explorer")
- {
- if(navigator.appVersion.match(/7./i)=='7.')
- {
- //是IE7,不跳转
- }
- else
- {
- //不是,跳转
- location.href='http://127.0.0.1';
- }
- }
- }
- </script>
复制代码
方法二:- <span id="Css"></span>
- <script>
- if(navigator.userAgent.indexOf("MSIE")>0)
- {
- //是否是IE浏览器
- if(navigator.userAgent.indexOf("MSIE 6.0")>0)
- {
- //6.0 使用1.CSS
- Css.innerHTML='<link href="1.css" rel="stylesheet" type="text/css" >'
- }
- if(navigator.userAgent.indexOf("MSIE 7.0")>0)
- {
- //7.0 使用2.CSS
- Css.innerHTML='<link href="2.css" rel="stylesheet" type="text/css" >'
- }
- }else
- {
- //否则使用3.CSS 还有具体的浏览器 你可以用navigator.userAgent 去获取信息 具体使用 看你自己
- Css.innerHTML='<link href="3.css" rel="stylesheet" type="text/css" >'
- }
- </script>
复制代码
方法三:- <html>
- <head>
- <link href="1.css" rel="stylesheet" type="text/css" id="MyCSS">
- </head>
- <body>
- <script type="text/javascript">
- function changeCss()
- {
- document.getElementById("MyCSS").href="2.css";
- }
- </script>
- <div id="ts">test</div>
- <input type="button" value="Change">
- </body>
- </html>
复制代码 |