JavaScript实现IE6以下版本提示更新.

Navigator

获取浏览器的名称

var browser=navigator.appName

获取浏览器的版本

var b_version=navigator.appVersion  

进行对IE5.5 and IE6.0判断

if(b_version.indexOf("MSIE 6.0") != -1 || b_version.indexOf("MSIE 5.5") != -1){

如果条件成立,则对其执行:

document.getElementById("ie6").style.display = "block";

否则

alert("您目前使用的浏览器无需更新!")

整体代码:

 
  
<! DOCTYPE HTML >
< html >
< head >
< title > New Document </ title >

< style type ="text/css" >
*
{ margin : 0 ; padding : 0 ; }
ul
{ list-style : none outside none ; }
#ie6
{ text-align : center ; line-height : 30px ; display : none }
</ style >


</ head >

< body onload ="detectBrowser()" >
< script type ="text/javascript" >
function detectBrowser()
{
var browser = navigator.appName
var b_version = navigator.appVersion
if (b_version.indexOf( " MSIE 6.0 " ) != - 1 || b_version.indexOf( " MSIE 5.5 " ) != - 1 ){
document.getElementById(
" ie6 " ).style.display = " block " ;
}
else {
alert(
" 您目前使用的浏览器无需更新! " )
}
}
// alert(navigator.appVersion)
// alert(navigator.appName)
</ script >
< div id ="ie6" >
< h1 > 警告 </ h1 >
< p > 您目前使用的浏览器版本过于陈旧,请您立即更新你的浏览器! </ p >
< p >< a href ="http://www.google.com/chrome/eula.html" > Chrome </ a > < a href ="http://www.mozilla.com/en-US/firefox/new/" > Firefox </ a > < a href ="http://www.opera.com/" > Opera </ a > < a href ="http://www.apple.com.cn/safari/download/" > Safari </ a > < a href ="http://info.msn.com.cn/ie9/" > Internet Explorer 9 </ a ></ p >
</ div >
</ body >
</ html >

转载于:https://www.cnblogs.com/blueDream2011/archive/2011/04/10/2011706.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值