
仿WINODWS警告提示Firefox广告
- 2008-03-3
- 分类:JavaScript
- 作者:银子
- 393 次查看
不知道效果如何,先挂在自己的表情站上试试,毕竟google广告里最有价值的还是Firefox的广告推荐了
实现代码如下:
先在 < body > 后加上这么一段
- <div id="firefox">
- <a href="/firefox/" target="_new">还在用过时的IE浏览器?远离网络病毒,木马,恶意软件的入侵攻击,强烈建议下载安装【最快.最安全】的浏览器:火狐Firefox2.0</a>
- <img src="close.gif" id="foxclose" />
- </div>
- <script type="text/javascript" src="firefox.js"></script>
CSS部分:
- #firefox {
- height:25px;
- width:100%;
- background:url(warning.gif) no-repeat 8px 3px #ffb;
- border-bottom:1px solid #ffdb4d;
- line-height:25px;
- display:none;
- }
- #firefox a {
- color:#52271d;
- float:left;
- margin-left:170px;
- }
- #firefox img {
- dispaly:block;
- float:right;
- margin:7px 6px 0 0;
- cursor:pointer;
- }
引用的JS文件内容:
- /**
- *FileName:firefox.js
- *Author:wuleying
- */
- var firefox = document.getElementById("firefox");
- var foxclose = document.getElementById("foxclose");
- if(window.ActiveXObject && getCookie("firecookie") != 1){firefox.style.display = "block";}
- foxclose.onclick = function()
- {
- firefox.style.display = "none";
- setCookie("firecookie",1,12);
- }
- //写入cookie
- function setCookie(name,value,hours)
- {
- var expire = "";
- if(hours != null)
- {
- expire = new Date((new Date()).getTime() + hours * 3600000);
- expire = ";expires=" + expire.toGMTString();
- }
- document.cookie = name + "=" + escape(value) + expire;
- }
- //读取cookie
- function getCookie(name)
- {
- var cookieValue = "";
- var search = 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))
- }
- }
- return cookieValue;
- }
判断了是否IE浏览器.并且记录了COOKIE
Demo:www.qqdang.net
NOTE:本博内容大部分为原创,转载请注明出处。
永久链接:http://www.zdyi.com/index.php/firefox-windows-warning/60.html

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