国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

javascript實現仿IE頂部的可關閉警告條

2019-11-20 12:33:24
字體:
來源:轉載
供稿:網友

功能非常實用,代碼非常簡單,就不多廢話了,直接奉上:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>仿IE頂部的警告條,可以關閉</title><style type="text/css">#informationbar{position: fixed;left: 0;width: 100%;text-indent: 5px;padding: 5px 0;background-color: lightyellow;border-bottom: 1px solid black;font: bold 12px Verdana;}* html #informationbar{ /*IE6 hack*/position: absolute;width: expression(document.compatMode=="CSS1Compat"? document.documentElement.clientWidth+"px" : body.clientWidth+"px");}</style><script type="text/javascript">function informationbar(){this.displayfreq="always"this.content='<a href="javascript:informationbar.close()"><img src="close.gif" style="width: 14px; height: 14px; float: right; border: 0; margin-right: 5px"/></a>'}informationbar.prototype.setContent=function(data){this.content=this.content+datadocument.write('<div id="informationbar" style="top: -500px">'+this.content+'</div>')}informationbar.prototype.animatetoview=function(){var barinstance=thisif (parseInt(this.barref.style.top)<0){this.barref.style.top=parseInt(this.barref.style.top)+5+"px"setTimeout(function(){barinstance.animatetoview()}, 50)}else{if (document.all && !window.XMLHttpRequest)this.barref.style.setExpression("top", 'document.compatMode=="CSS1Compat"? document.documentElement.scrollTop+"px" : body.scrollTop+"px"')elsethis.barref.style.top=0}}informationbar.close=function(){document.getElementById("informationbar").style.display="none"if (this.displayfreq=="session")document.cookie="infobarshown=1;path=/"}informationbar.prototype.setfrequency=function(type){this.displayfreq=type}informationbar.prototype.initialize=function(){if (this.displayfreq=="session" && document.cookie.indexOf("infobarshown")==-1 || this.displayfreq=="always"){this.barref=document.getElementById("informationbar")this.barheight=parseInt(this.barref.offsetHeight)this.barref.style.top=this.barheight*(-1)+"px"this.animatetoview()}}window.onunload=function(){this.barref=null}</script><script type="text/javascript"><!--Invocation code-->var infobar=new informationbar()infobar.setContent('敬告:明天中午12點天降錢雨,請備好麻袋!  <a href="#">購買麻袋</a>  <a href="#">購買麻袋</a>')infobar.initialize()</script></head><body></body></html>

以上所述就是本文的全部內容了,希望大家能夠喜歡。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 神池县| 子洲县| 会同县| 黑水县| 阳江市| 宁乡县| 阆中市| 赤水市| 海城市| 威海市| 扶沟县| 耿马| 新河县| 和政县| 石河子市| 福贡县| 上高县| 交口县| 利辛县| 澄江县| 屯门区| 盘山县| 杭锦后旗| 齐河县| 五寨县| 芦山县| 平原县| 辽阳市| 宣威市| 凌源市| 纳雍县| 盘锦市| 邵阳市| 扬州市| 康乐县| 北辰区| 天镇县| 巴林右旗| 逊克县| 龙海市| 彝良县|