关于谷歌和IE内核兼容性问题

问题:

透明背景png图片,ie6中显示边框。

解决:

png有两种格式,IE6只支持较早版本的格式。


问题:

判断浏览器版本,跳转不同链接。

解决:

在body之间,插入如下,判断是否为IE浏览器

<script type="text/javascript">
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :

if(Sys.ie){

window.location ="你的网址";
}

else{
window.location ="你的网址";
}
</script>
    如果进一步确定浏览器类型,如Google chrome、Firefox、Opera、Safari等
<script type="text/javascript">
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
if(Sys.ie){
window.location ="你的地址";
}
//else if(Sys.chrome){window.location ="你的地址";}
//else if(Sys.opera){window.location ="你的地址";}
//else if(Sys.firefox){window.location ="你的地址";}
//else if(Sys.safari){window.location ="你的地址";}
else{
window.location ="你的地址";
}
</script> 
问题:
	判断IE浏览器版本。
解决:
	条件注释:如果IE8则百度,小于等于IE7则谷歌
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	自动跳转测试
	<!--[if IE 8]>
 		<script type="text/javascript">
			window.location="http://www.baidu.com";
		</script>
	<![endif]-->
	<!--[if lte IE 7]>
 		<script type="text/javascript">
			window.location="http://www.google.com";
		</script>
	<![endif]-->
注:
条件注释-lte:小于等于;lt:小于;gte:大于等于;gt:大于;[if !IE]:不是IE;[if IE]:是IE
 
	判断网页是否IE8,如果是正常显示,不是则跳转到百度
<script type="text/javascript" language="javascript">
function getIE()
{
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        if(navigator.appVersion.match(/8./i)=='8.')
        {
     }
        else
        {
     location.href='http://www.baidu.com';
        }
    }
}
</script>

 
	判断是否IE8及以上,正常跳转,低于IE8则跳转百度。
<script type="text/javascript" language="javascript">
function getIE()
{
    if(navigator.appName == "Microsoft Internet Explorer")
    {
        if(navigator.appVersion.match(/8./i)=='8.' || navigator.appVersion.match(/9./i)=='9.')
        {
     }
        else
        {
     location.href='http://www.baidu.com';
        }
    }
}
</script>

 
	判断IE6,指定使用的CSS样式
<script type="text/javascript">
//识别是否使用IE浏览器
if(navigator.userAgent.indexOf("MSIE")>0)
{
//判断结果为IE8.0 则使用ie8.CSS
if(navigator.userAgent.indexOf("MSIE 8.0")>0)
{
Css.innerHTML='<link href="path/ie8.css" rel="stylesheet" type="text/css" >'
}
//判断结果为IE6.0 则使用ie6.CSS
if(navigator.userAgent.indexOf("MSIE 6.0")>0)
{
Css.innerHTML='<link href="path/ie6.css" rel="stylesheet" type="text/css" >'
}
//否则使用css.CSS
}else
{
Css.innerHTML='<link href="path/css.css" rel="stylesheet" type="text/css" >'
}
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值