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

首頁(yè) > 語(yǔ)言 > JavaScript > 正文

javascript實(shí)現(xiàn)仿IE頂部的可關(guān)閉警告條

2024-05-06 16:19:20
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

仿windows IE頂部的敬告工具條,帶關(guān)閉按鈕,設(shè)計(jì)還算精美,你完全可以用到自己的網(wǎng)頁(yè)用于顯示提示等方面,有需要的小伙伴可以參考下。

功能非常實(shí)用,代碼非常簡(jiǎn)單,就不多廢話了,直接奉上:

 

 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  2. <html xmlns="http://www.w3.org/1999/xhtml"
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  5. <title>仿IE頂部的警告條,可以關(guān)閉</title> 
  6. <style type="text/css"
  7. #informationbar{ 
  8. position: fixed; 
  9. left: 0; 
  10. width: 100%; 
  11. text-indent: 5px; 
  12. padding: 5px 0; 
  13. background-color: lightyellow; 
  14. border-bottom: 1px solid black; 
  15. font: bold 12px Verdana; 
  16. * html #informationbar{ /*IE6 hack*/ 
  17. position: absolute; 
  18. width: expression(document.compatMode=="CSS1Compat"? document.documentElement.clientWidth+"px" : body.clientWidth+"px"); 
  19. </style> 
  20. <script type="text/javascript"
  21. function informationbar(){ 
  22. this.displayfreq="always" 
  23. this.content='<a href="javascript:informationbar.close()"><img src="close.gif" style="width: 14px; height: 14px; float: right; border: 0; margin-right: 5px" 
  24.  
  25. /></a>' 
  26. informationbar.prototype.setContent=function(data){ 
  27. this.content=this.content+data 
  28. document.write('<div id="informationbar" style="top: -500px">'+this.content+'</div>'
  29. informationbar.prototype.animatetoview=function(){ 
  30. var barinstance=this 
  31. if (parseInt(this.barref.style.top)<0){ 
  32. this.barref.style.top=parseInt(this.barref.style.top)+5+"px" 
  33. setTimeout(function(){barinstance.animatetoview()}, 50) 
  34. else
  35. if (document.all && !window.XMLHttpRequest) 
  36. this.barref.style.setExpression("top"'document.compatMode=="CSS1Compat"? document.documentElement.scrollTop+"px" : body.scrollTop+"px"'
  37. else 
  38. this.barref.style.top=0 
  39. informationbar.close=function(){ 
  40. document.getElementById("informationbar").style.display="none" 
  41. if (this.displayfreq=="session"
  42. document.cookie="infobarshown=1;path=/" 
  43. informationbar.prototype.setfrequency=function(type){ 
  44. this.displayfreq=type 
  45. informationbar.prototype.initialize=function(){ 
  46. if (this.displayfreq=="session" && document.cookie.indexOf("infobarshown")==-1 || this.displayfreq=="always"){ 
  47. this.barref=document.getElementById("informationbar"
  48. this.barheight=parseInt(this.barref.offsetHeight) 
  49. this.barref.style.top=this.barheight*(-1)+"px" 
  50. this.animatetoview() 
  51. window.onunload=function(){ 
  52. this.barref=null 
  53. </script> 
  54. <script type="text/javascript"
  55. <!--Invocation code--> 
  56. var infobar=new informationbar() 
  57. infobar.setContent('敬告:明天中午12點(diǎn)天降錢雨,請(qǐng)備好麻袋!  <a href="#">購(gòu)買麻袋</a>  <a href="#">購(gòu)買麻袋</a>'
  58. infobar.initialize() 
  59. </script> 
  60. </head> 
  61. <body> 
  62. </body> 
  63. </html> 

以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 彩票| 托里县| 东明县| 东兴市| 武清区| 淳化县| 陆川县| 涿鹿县| 浦东新区| 鹿泉市| 彰化市| 哈巴河县| 泽库县| 石渠县| 嫩江县| 达日县| 盘锦市| 夏河县| 景宁| 黔南| 武山县| 兴山县| 瑞金市| 福鼎市| 修武县| 阜康市| 津市市| 陈巴尔虎旗| 神池县| 彰武县| 虞城县| 牙克石市| 徐水县| 息烽县| 福海县| 西宁市| 安陆市| 财经| 民权县| 白河县| 溧阳市|