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

首頁 > 語言 > JavaScript > 正文

javascript實現簡單的頁面右下角提示信息框

2024-05-06 16:24:09
字體:
來源:轉載
供稿:網友

本文給大家分享的是使用javascript實現簡單的頁面右下角提示信息框的方法和示例代碼,有需要的小伙伴可以參考下。

由于之前找到一個開源的很好用,可以固定在瀏覽器的右下角;兼容性也很好;加上之后影響到應用的一個小功能點,決定重寫一個;這個只能固定在當前頁面的右下加,系統是上下結構滿足需求,沒在繼續擴展;

兩個函數:

1.lay -- 設置提示框高寬(可選)

2.show -- 設置標題,內容,和停留時間

notice.js

 

 
  1. var time; 
  2. var delayTime; 
  3. $(function(){ 
  4. // 增加浮動DIV 
  5. $('body').append("<div id='notice' onselectstart='return false'><span class='notice_title'></span><span class='cbtn'>[關閉]</span><div class='notice_content'></div></div>"); 
  6.  
  7. // 更改樣式 
  8. $('#notice').css({right:"0",bottom:"0",cursor:"default",position:"fixed","background-color":"#CFDEF4",color:"#1F336B","z-index":"999",border:"1px #1F336B solid",margin:"2px",padding:"10px","font-weight":"bold","line-height":"25px",display:"none"}); 
  9. $('#notice .cbtn').css({color:"#FF0000",cursor:"pointer","padding-right":"5px",float:"right",position:"relative"}); 
  10. $('#notice .notice_content').css({margin:"3px","font-weight":"normal",border:"1px #B9C9EF solid","line-height":"20px","margin-bottom":"10px",padding:"10px"}); 
  11.  
  12. /* 綁定事件*/ 
  13. $('#notice').hover( 
  14. function(){ 
  15. $(this).stop(true,true).slideDown(); 
  16. clearTimeout(time); 
  17. }, 
  18. function(){ 
  19. time = setTimeout('_notice()',delayTime); 
  20. ); 
  21.  
  22. //綁定關閉事件 
  23. $('.cbtn').bind('click',function(){ 
  24. $('#notice').slideUp('fast'); 
  25. clearTimeout(time); 
  26. }); 
  27. }); 
  28. $.extend({ 
  29. lay:function(_width,_height){ 
  30. $('#notice').css({width:_width,height:_height}); 
  31. }, 
  32. show:function(_title,_msg,_time){ 
  33. delayTime = _time; 
  34. $('.notice_title').html(_title); 
  35. $('.notice_content').html(_msg); 
  36. $('#notice').slideDown(2000); 
  37. time = setTimeout('_notice()',delayTime); 
  38. }, 
  39. }); 
  40. function _notice(){ 
  41. $('#notice').slideUp(2000); 

index.html

 

 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  2. <html> 
  3. <head> 
  4. <title>index.html</title> 
  5.  
  6. <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/> 
  7. <meta http-equiv="description" content="this is my page"/> 
  8. <meta http-equiv="content-type" content="text/html; charset=GBK"/> 
  9.  
  10. <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> 
  11.  
  12. </head> 
  13.  
  14. <body onload='initPage();'
  15. </body> 
  16. <script type="text/javascript"
  17. function initPage(){ 
  18. var returnMsg = "<p>信息1 jquery-1.7.2.min.js</p><p>信息2 notice.js</p><p>信息3</p>"
  19. $.show('提示信息',returnMsg,10000); 
  20. </script> 
  21. <script src="jquery-1.7.2.min.js" type="text/javascript" ></script> 
  22. <script src="notice.js" type="text/javascript" ></script> 
  23. </html> 

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 冕宁县| 桑日县| 安岳县| 西峡县| 张家港市| 陵川县| 青海省| 永登县| 平江县| 梅河口市| 榆林市| 西峡县| 仪陇县| 苍溪县| 陵川县| 都江堰市| 乐昌市| 石台县| 长汀县| 应用必备| 隆昌县| 宁蒗| 逊克县| 峨山| 重庆市| 潍坊市| 平安县| 桃园县| 和田县| 台南县| 鲁甸县| 普定县| 资溪县| 厦门市| 文成县| 抚州市| 荣昌县| 城市| 建阳市| 龙陵县| 大渡口区|