仿WINODWS警告提示Firefox广告

不知道效果如何,先挂在自己的表情站上试试,毕竟google广告里最有价值的还是Firefox的广告推荐了

实现代码如下:

先在 < body > 后加上这么一段

  1. <div id="firefox">
  2. <a href="/firefox/" target="_new">还在用过时的IE浏览器?远离网络病毒,木马,恶意软件的入侵攻击,强烈建议下载安装【最快.最安全】的浏览器:火狐Firefox2.0</a>
  3. <img src="close.gif" id="foxclose" />
  4. </div>
  5. <script type="text/javascript" src="firefox.js"></script>

CSS部分:

  1. #firefox {
  2.     height:25px;
  3.     width:100%;
  4.     background:url(warning.gif) no-repeat 8px 3px #ffb;
  5.     border-bottom:1px solid #ffdb4d;
  6.     line-height:25px;
  7.     display:none;
  8. }
  9.  
  10. #firefox a {
  11.     color:#52271d;
  12.     float:left;
  13.     margin-left:170px;
  14. }
  15.  
  16. #firefox img {
  17.     dispaly:block;
  18.     float:right;
  19.     margin:7px 6px 0 0;
  20.     cursor:pointer;
  21. }

引用的JS文件内容:

  1. /**
  2. *FileName:firefox.js
  3. *Author:wuleying
  4. */
  5. var firefox = document.getElementById("firefox");
  6. var foxclose = document.getElementById("foxclose");
  7. if(window.ActiveXObject && getCookie("firecookie") != 1){firefox.style.display = "block";}
  8. foxclose.onclick = function()
  9. {
  10.     firefox.style.display = "none";
  11.     setCookie("firecookie",1,12);
  12. }
  13.  
  14. //写入cookie
  15. function setCookie(name,value,hours)  
  16. {  
  17.     var expire = "";  
  18.     if(hours != null)  
  19.     {  
  20.         expire = new Date((new Date()).getTime() + hours * 3600000);  
  21.         expire = ";expires=" + expire.toGMTString();  
  22.     }  
  23.     document.cookie = name + "=" + escape(value) + expire;  
  24. } 
  25.  
  26. //读取cookie
  27. function getCookie(name)  
  28. {  
  29.     var cookieValue = "";  
  30.     var search = name + "=";  
  31.     if(document.cookie.length > 0)  
  32.     {    
  33.         offset = document.cookie.indexOf(search);  
  34.         if (offset != -1)  
  35.         {    
  36.             offset += search.length;  
  37.             end = document.cookie.indexOf(";",   offset);  
  38.             if(end == -1) end = document.cookie.length;  
  39.             cookieValue = unescape(document.cookie.substring(offset,end))  
  40.         }  
  41.     }  
  42.     return cookieValue;  
  43. }

判断了是否IE浏览器.并且记录了COOKIE

Demo:www.qqdang.net

2 条评论

  1. 纸黄金

    哦明白了

  2. iamzhongshi

    呵呵…我还一直以为是系统中毒报错呢..
    原来是这样回事啊

发表评论

验证码: 验证码看不清发泄点这里

 

浏览最多的10篇日志

评论最多的10篇日志

随机显示的10篇日志