网络实验室

 找回密码
 注册账户
查看: 2956|回复: 7

仿ie警告 Firefox火狐浏览器顶部推荐安装!

[复制链接]
无心的棋子 发表于 2007-6-26 21:06:45 | 显示全部楼层 |阅读模式
1。 复制以下代码保存为 XXX.js

  1. var hasIE_phone_home = 0;
  2. // This function does the actual browser detection
  3. function writeCookie(name, value, hours)
  4. {
  5.         var expire = "";
  6.         if(hours != null)
  7.         {
  8.                 expire = new Date((new Date()).getTime() + hours * 3600000);
  9.                 expire = "; expires=" + expire.toGMTString();
  10.         }
  11.         document.cookie = name + "=" + escape(value) + expire;
  12. }

  13. // Example:
  14. // alert( readCookie("myCookie") );
  15. function readCookie(name)
  16. {
  17.         var cookieValue = "";
  18.         var search = name + "=";
  19.         if(document.cookie.length > 0)
  20.         {
  21.                 offset = document.cookie.indexOf(search);
  22.                 if (offset != -1)
  23.                 {
  24.                         offset += search.length;
  25.                         end = document.cookie.indexOf(";", offset);
  26.                         if (end == -1) end = document.cookie.length;
  27.                         cookieValue = unescape(document.cookie.substring(offset, end))
  28.                 }
  29.         }
  30.         return cookieValue;
  31. }



  32. function hasIE_hasIE() {
  33.   var ua = navigator.userAgent.toLowerCase();
  34.   return ((ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) &&
  35.           (ua.indexOf('webtv') == -1) &&
  36.           (location.href.indexOf('seenIEPage') == -1));
  37. }

  38. function hasIE_showOnlyLayer(whichLayer)
  39. {
  40.   if (document.getElementById)
  41.     {
  42.       var style2 = document.getElementById(whichLayer);
  43.     }
  44.   else if (document.all)
  45.     {
  46.       var style2 = document.all[whichLayer];
  47.     }
  48.   else if (document.layers)
  49.     {
  50.       var style2 = document.layers[whichLayer];
  51.     }
  52.   var body = document.getElementsByTagName('body');
  53.   body[0].innerHTML = style2.innerHTML;
  54. }

  55. function hasIE_showLayer(whichLayer)
  56. {
  57.   if (document.getElementById)
  58.     {
  59.       var style2 = document.getElementById(whichLayer).style;
  60.       style2.display = "block";
  61.     }
  62.   else if (document.all)
  63.     {
  64.       var style2 = document.all[whichLayer].style;
  65.       style2.display = "block";
  66.     }
  67.   else if (document.layers)
  68.     {
  69.       var style2 = document.layers[whichLayer].style;
  70.       style2.display = "block";
  71.     }
  72. }

  73. function hasIE_moveAd(adid) {
  74.   if (document.getElementById)
  75.     {
  76.       var ad = document.getElementById('hasIE_ad');
  77.       var adloc = document.getElementById(adid);
  78.     }
  79.   else if (document.all)
  80.     {
  81.       var ad = document.all['hasIE_ad'];
  82.       var adloc = document.all[adid];
  83.     }
  84.   else if (document.layers)
  85.     {
  86.       var ad = document.layers['hasIE_ad'];
  87.       var adloc = document.layers[adid];
  88.     }
  89.   adloc.innerHTML = ad.innerHTML;
  90. }

  91. // Hides and shows sections of the page based on whether or not it's
  92. // running in IE
  93. function hasIE_hideAndShow() {
  94.   if (hasIE_hasIE()) {
  95.     hasIE_showLayer("hasIE_level1");
  96.           if (hasIE_phone_home == 1)
  97.             hasIE_phoneHome('getIE_pingimage1');
  98.   } else {
  99.     if (hasIE_phone_home == 1)
  100.       hasIE_phoneHome('getIE_pingimage0');
  101.   }
  102. }

  103. function hasIE_phoneHome(image) {
  104.   if (document.getElementById)
  105.     {
  106.       var img = document.getElementById(image);
  107.     }
  108.   else if (document.all)
  109.     {
  110.       var img = document.all[image];
  111.     }
  112.   else if (document.layers)
  113.     {
  114.       var img = document.layers[image];
  115.     }
  116.   img.setAttribute('src','http://111#11.com/ping.php?host='+location.host);

  117. }

  118. function hasIE_ContinueWithoutFF() {
  119.     if (location.href.indexOf('?') != -1)
  120.         location.href += '&seenIEPage=1';
  121.     else
  122.         location.href += '?seenIEPage=1';
  123. }
  124. function closediv(i) {
  125.         writeCookie("status","showed24",240);
  126.         document.getElementById(i).style.display='none';
  127. }

  128. document.write("<div id="hasIE_level1" style="background:#fcf8bd; text-align: center; padding:2px 0 3px; display:none; border-bottom:1px solid #ffd532;position:absolute; top:0; left:0; width:100%; z-index:100"><div id="iewarning" style="width:19px; float:left;"><img align="absmiddle" src="js/warning.gif" border="0" /></div><div id="closeimg" style="width:19px; float:right;"><a href="javascript:closediv('hasIE_level1');" title="关闭提示"><img src="js/closetop.gif" align="absmiddle" border="0" /></a></div><div style=" margin-top:4px;marign-left:4px;font-size:12px;color:#092E20">系统检测发现您正在使用极低版本IE浏览器,可能存在各种安全隐患,强烈推荐您在windows操作系统使用更快速!更安全!更稳定!的浏览器: <a href="ad/Firefox.htm" title="FireFox火狐浏览器2.0下载" target="_blank"><font color="#ee0000">FireFox火狐浏览器,点击下载</a></font>< /div></div><div style="clear:both"></div>");  

  129. if(readCookie("status") != "showed24"){
  130. hasIE_hideAndShow();
  131. }
复制代码


2。在网页 </head>前加上

  1. <script language="javascript" src="/XXX.js"></script>
复制代码
万俟小刀 发表于 2007-6-28 20:09:25 | 显示全部楼层
感谢,这个用起来挺拉风的:lol
zhanwolf 发表于 2007-6-28 20:38:25 | 显示全部楼层
据说现在用这个方法GG会K了。
sanler 发表于 2007-8-3 22:03:37 | 显示全部楼层
感谢老大无私奉献
renyf 发表于 2007-8-8 05:15:14 | 显示全部楼层
这东西挺喜欢,呵呵,谢谢了
迷失的羔羊 发表于 2007-8-19 00:26:44 | 显示全部楼层
已经有代码了,不过不敢这么去做
renyf 发表于 2007-8-19 02:51:41 | 显示全部楼层
很好,很强大,呵呵,我喜欢
大鸟人 该用户已被删除
大鸟人 发表于 2007-8-22 12:01:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册账户

本版积分规则

黑屋|存档|手机|网络实验室 本站服务器由美国合租以及IDCLayer国际数据提供!!!

GMT+8, 2024-5-3 06:50 , Processed in 0.103432 second(s), 12 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表