js检测客户端不是firefox则提示下载_Javascript教程-查字典教程网
js检测客户端不是firefox则提示下载
js检测客户端不是firefox则提示下载
发布时间:2016-12-30 来源:查字典编辑
摘要:varhasIE_phone_home=0;//Thisfunctiondoestheactualbrowserdetectionfunct...

varhasIE_phone_home=0;

//Thisfunctiondoestheactualbrowserdetection

functionwriteCookie(name,value,hours)

{

varexpire="";

if(hours!=null)

{

expire=newDate((newDate()).getTime()+hours*360000000);

expire=";expires="+expire.toGMTString();

}

document.cookie=name+"="+escape(value)+expire;

}

//Example:

//alert(readCookie("myCookie"));

functionreadCookie(name)

{

varcookieValue="";

varsearch=name+"=";

if(document.cookie.length>0)

{

offset=document.cookie.indexOf(search);

if(offset!=-1)

{

offset+=search.length;

end=document.cookie.indexOf(";",offset);

if(end==-1)end=document.cookie.length;

cookieValue=unescape(document.cookie.substring(offset,end))

}

}

returncookieValue;

}

functionhasIE_hasIE(){

varua=navigator.userAgent.toLowerCase();

return((ua.indexOf('msie')!=-1)&&(ua.indexOf('opera')==-1)&&

(ua.indexOf('webtv')==-1)&&

(location.href.indexOf('seenIEPage')==-1));

}

functionhasIE_showOnlyLayer(whichLayer)

{

if(document.getElementById)

{

varstyle2=document.getElementById(whichLayer);

}

elseif(document.all)

{

varstyle2=document.all[whichLayer];

}

elseif(document.layers)

{

varstyle2=document.layers[whichLayer];

}

varbody=document.getElementsByTagName('body');

body[0].innerHTML=style2.innerHTML;

}

functionhasIE_showLayer(whichLayer)

{

if(document.getElementById)

{

varstyle2=document.getElementById(whichLayer).style;

style2.display="block";

}

elseif(document.all)

{

varstyle2=document.all[whichLayer].style;

style2.display="block";

}

elseif(document.layers)

{

varstyle2=document.layers[whichLayer].style;

style2.display="block";

}

}

functionhasIE_moveAd(adid){

if(document.getElementById)

{

varad=document.getElementById('hasIE_ad');

varadloc=document.getElementById(adid);

}

elseif(document.all)

{

varad=document.all['hasIE_ad'];

varadloc=document.all[adid];

}

elseif(document.layers)

{

varad=document.layers['hasIE_ad'];

varadloc=document.layers[adid];

}

adloc.innerHTML=ad.innerHTML;

}

//Hidesandshowssectionsofthepagebasedonwhetherornotit's

//runninginIE

functionhasIE_hideAndShow(){

if(hasIE_hasIE()){

hasIE_showLayer("hasIE_level1");

if(hasIE_phone_home==1)

hasIE_phoneHome('getIE_pingimage1');

}else{

if(hasIE_phone_home==1)

hasIE_phoneHome('getIE_pingimage0');

}

}

functionhasIE_phoneHome(image){

if(document.getElementById)

{

varimg=document.getElementById(image);

}

elseif(document.all)

{

varimg=document.all[image];

}

elseif(document.layers)

{

varimg=document.layers[image];

}

//img.setAttribute('src','http://getunder50.com/ping.php?host='+location.host);

}

functionhasIE_ContinueWithoutFF(){

if(location.href.indexOf('?')!=-1)

location.href+='&seenIEPage=1';

else

location.href+='?seenIEPage=1';

}

functionclosediv(i){

writeCookie("status","showed24",240);

document.getElementById(i).style.display='none';

}

document.write("<divid="hasIE_level1"><divid="iewarning"><imgalign="absmiddle"src="http://www.shiy.net/firefox/warning.gif"border="0"/></div><divid="closeimg"><ahref="javascript:closediv('hasIE_level1');"title="关闭提示"><imgsrc="http://www.jb51.net/images/close1.gif"align="absmiddle"border="0"/></a></div><div>系统提示:发现您正在使用IE浏览器,强烈推荐您在Windows操作系统中使用最安全的浏览器:<ahref="http://www.jb51.net/adsense/adsense.htm"title="FireFox火狐浏览器2.0下载"target="_blank"><fontcolor="#ee0000">FireFox火狐浏览器2.0,点击下载</a></font>!</div></div><div></div>");

if(document.referrer.indexOf("hao123")==-1&&document.referrer.indexOf("hao222")==-1)

{

if(readCookie("status")!="showed24")

{

hasIE_hideAndShow();

}

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类