Javascript 基于ie浏览器版本的网站重定向
我有一个由IE8支持的网站正在运行。我想用一个新的网站来取代它,但是IE8不支持这个新网站。如果浏览器版本低于IE9,是否有办法重定向新网站以显示旧网站本身。 (网站完全采用html n css格式)Javascript 基于ie浏览器版本的网站重定向,javascript,internet-explorer,Javascript,Internet Explorer,我有一个由IE8支持的网站正在运行。我想用一个新的网站来取代它,但是IE8不支持这个新网站。如果浏览器版本低于IE9,是否有办法重定向新网站以显示旧网站本身。 (网站完全采用html n css格式) 谢谢。只要把这几行写在最上面就行了 <!--[if IE 8 ]> <META http-equiv="refresh" content="0;URL=http://oldurl.com"> <![endif]--> 用ie8支持的url替换oldu
谢谢。只要把这几行写在最上面就行了
<!--[if IE 8 ]> <META http-equiv="refresh" content="0;URL=http://oldurl.com"> <![endif]-->
用ie8支持的url替换oldurl.com首先正确设置ie类
<!doctype html>
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
<head>
And add some simple script:
(function ($) {
"use strict";
// Detecting IE
var oldIE;
if ($('html').is('.ie6, .ie7, .ie8')) {
oldIE = true;
}
if (oldIE) {
window.location.href="new url";
} else {
// ..And here's the full-fat code for everyone else
}
}(jQuery));
并添加一些简单的脚本:
(函数($){
“严格使用”;
//检测IE
var oldIE;
如果($('html')。是('.ie6、.ie7、.ie8')){
老话=真;
}
如果(老调){
window.location.href=“新建url”;
}否则{
//这是其他人的完整fat代码
}
}(jQuery));
来源-这是浏览器嗅探技术。一点也不推荐。另外,HTML5样板文件中关于
index.html
的文档值得一读。成功了。我必须退出浏览器并清除缓存。非常感谢sanjeev