巧用JS程序,制作有趣的网站提醒

     如果你经常上网的话,也许大家在许多地方都会看到在网页的上方看到“发现您正在使用老掉牙的IE浏览器,强烈推荐您在Windows 操作系统中使用最安全的浏览器:FireFox火狐浏览器2.0,点击下载!”这样的话,今天就给大家说说它的做法。  不过说实话,你点了下了装了,你就给别人赚钱了。。。自己想吧
     写一个JS程序调用就可以了。然后首页调用
        <script src="http://www.你的域名.com/FireFox.js" type="text/javascript"></script>

下面是JS文件内容,修改下域名就行。要美观的话就补充两个小图片。

 

function writeCookie(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;
 }
 
 // Example:
 // alert( readCookie("myCookie") );
 function readCookie(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;
 }
 
 
 
 function hasIE_hasIE() {
 var ua = navigator.userAgent.toLowerCase();
 return ((ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) &&
 (ua.indexOf('webtv') == -1) &&
 (location.href.indexOf('seenIEPage') == -1));
 }
 
 function hasIE_showLayer(whichLayer)
 {
 if (document.getElementById)
 {
 var style2 = document.getElementById(whichLayer).style;
 style2.display = "block";
 }
 else if (document.all)
 {
 var style2 = document.all[whichLayer].style;
 style2.display = "block";
 }
 else if (document.layers)
 {
 var style2 = document.layers[whichLayer].style;
 style2.display = "block";
 }
 }
 
 // Hides and shows sections of the page based on whether or not it's
 // running in IE
 function hasIE_hideAndShow()
 {
 if (hasIE_hasIE())
 {
 hasIE_showLayer("hasIE_level1");
 }
 else{}
 }
 
 function hasIE_ContinueWithoutFF() {
 if (location.href.indexOf('?') != -1)
 location.href += '&seenIEPage=1';
 else
 location.href += '?seenIEPage=1';
 }
 function closediv(i) {
 writeCookie("status","showed24",240);
 document.getElementById(i).style.display='none';
 }
 
 document.write("<div id=\"hasIE_level1\" style=\"background:#FFFFBB; 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=\"http://www.你的域名.net/images/warning.gif\" border=\"0\" /></div><div id=\"closeimg\" style=\"width:19px; float:right;\"><a href=\"javascript:closediv('hasIE_level1');\" title=\"关闭提示\"><img src=\"http://www.你的域名.net/images/close1.gif\" align=\"absmiddle\" border=\"0\" /></a></div><div style=\" margin-top:4px;marign-left:4px;font-size:12px;color:#092E20\"><a href=\"http://www.你的域名.com/firefox.htm\" target=_blank>为了您能够更流畅的访问本站,以及大大加快本站资源的下载速度,强烈建议您安装最好的浏览器: FireFox火狐浏览器2.0, <b>点这里下载!</b></a></div></div><div style=\"clear:both\"></div>");
 
 if(readCookie("status") != "showed24")
 {
 hasIE_hideAndShow();
 }

呵呵,试试哦,能赚美元$$$$$$$$$$

发表评论

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.