首页 > 语言 > JavaScript > 正文

纯js实现仿QQ邮箱弹出确认框

2024-05-06 16:19:00
字体:大 中 小
来源:转载
供稿:网友

仿QQ邮箱的弹出层,弹出确认框,主要是用火狐的firebug把html和css扣了下来,没有做封装,就定义了一个拖动事件. 大家可以封装自己的弹出窗,嘿嘿!

代码非常简单,这里就不多废话了。

  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>QQ邮箱的弹出层</TITLE> 
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  6. <style> 
  7. body { 
  8. background: none repeat scroll 0 0 #FFFFFF; 
  9. font-family: "lucida Grande",Verdana; 
  10. font-size: 12px; 
  11. } 
  12. select, body, textarea { 
  13. font-size: 12px; 
  14. } 
  15. .tipbg { 
  16. margin: 0; 
  17. padding: 0; 
  18. background-color: transparent; 
  19. } 
  20. .qmpanel_shadow { 
  21. border-radius: 3px 3px 3px 3px; 
  22. box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35); 
  23. } 
  24. .bd_upload { 
  25. border: 1px solid #628D0B; 
  26. } 
  27. .bd_upload { 
  28. border: 1px solid #628D0B; 
  29. } 
  30. .fdbody { 
  31. border-left: 8px solid #FFFFFF; 
  32. border-right: 1px solid #87A34D; 
  33. } 
  34. .fdbody, .tipstitle { 
  35. background: none repeat scroll 0 0 #9BBB59; 
  36. } 
  37. .editor_dialog_title { 
  38. color: white; 
  39. font: bold 12px "lucida Grande",Verdana; 
  40. padding: 9px 0 7px 10px; 
  41. text-align: left; 
  42. } 
  43. .editor_dialog_content { 
  44. background: none repeat scroll 0 0 #FFFFFF; 
  45. filter: none; 
  46. margin: 0; 
  47. padding: 0; 
  48. text-align: center; 
  49. } 
  50. .mailinfo { 
  51. border-bottom: 2px solid #FFFFFF; 
  52. } 
  53. .mailinfo { 
  54. background: none repeat scroll 0 0 #FFFFFF; 
  55. } 
  56. .cnfx_content { 
  57. padding: 10px 0 5px 10px; 
  58. text-align: left; 
  59. } 
  60. .cnfx_status { 
  61. float: left; 
  62. padding: 0 0 0 10px; 
  63. } 
  64. .cnfx_btn { 
  65. padding: 0 10px 10px 0; 
  66. text-align: right; 
  67. } 
  68. .b_size { 
  69. font-size: 14px; 
  70. } 
  71. .editor_close { 
  72. background: none repeat scroll 0 0 #DC4835; 
  73. } 
  74. /** when mouseover,add editor_close_mover*/ 
  75. .editor_close, .editor_close_mover { 
  76. border: 1px solid #A7190F; 
  77. cursor: pointer; 
  78. float: right; 
  79. margin: 7px 7px 0 0; 
  80. } 
  81. .editor_close img, .editor_close_mover img, .editor_min img, .editor_min_mover img { 
  82. display: block; 
  83. } 
  84. img { 
  85. border: medium none; 
  86. } 
  87. .wd2 { 
  88. margin: 1px 1px 0 0; 
  89. width: 64px; 
  90. } 
  91. .btn, button, .qm_btn { 
  92. padding-left: 0; 
  93. padding-right: 0; 
  94. } 
  95. input, textarea, a { 
  96. outline: medium none; 
  97. } 
  98. .editor_mask { 
  99. background: none repeat scroll 0 0 #FFFFFF; 
  100. height: 100%; 
  101. left: 0; 
  102. opacity: 0.5; 
  103. position: absolute; 
  104. top: 0; 
  105. width: 100%; 
  106. } 
  107. </style> 
  108. <script> 
  109. ///////// 拖拽工具类 //////// 
  110. var DragUtil = (function(){ 
  111. var doc = document; 
  112.  
  113. var moveX = 0; 
  114. var moveY = 0; 
  115. var moveTop = 0; 
  116. var moveLeft = 0; 
  117. var moveable = false; 
  118. return { 
  119. /** 
  120. * 注册拖拽 
  121. * 需要传入整个窗体id和标题部分的id 
  122. */ 
  123. regist:function(winId,titleId) { 
  124. // 页面头部要加上: 
  125. // <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  126. // 不然会有问题的 
  127. var width = doc.documentElement.clientWidth;  
  128. var height = doc.documentElement.clientHeight;  
  129. var title = doc.getElementById(titleId); 
  130. var win = doc.getElementById(winId); 
  131. title.onmousedown = function() { 
  132. var evt = DragUtil._getEvent(); 
  133.  
  134. moveable = true;  
  135. moveX = evt.clientX; 
  136. moveY = evt.clientY; 
  137.  
  138. moveTop = parseInt(win.style.top); 
  139. moveLeft = parseInt(win.style.left); 
  140.  
  141. doc.onmousemove = function() { 
  142. if (moveable) { 
  143. var evt = DragUtil._getEvent(); 
  144. var x = moveLeft + evt.clientX - moveX; 
  145.  
  146. var y = moveTop + evt.clientY - moveY; 
  147. var w = parseInt(win.style.width); 
  148. var h = parseInt(win.style.height); 
  149.  
  150.  
  151. if ( x > 0 &&( x + w < width) && y > 0 && (y + h < height) ) { 
  152. win.style.left = x + "px"; 
  153. win.style.top = y + "px"; 
  154. } 
  155. }  
  156. }; 
  157. doc.onmouseup = function () {  
  158. if (moveable) {  
  159. //doc.onmousemove = docMouseMoveEvent; 
  160. //doc.onmouseup = docMouseUpEvent; 
  161. moveable = false;  
  162. moveX = 0; 
  163. moveY = 0; 
  164. moveTop = 0; 
  165. moveLeft = 0; 
  166. }  
  167. }; 
  168. } 
  169. } 
  170. /** 
  171. * 获取事件 
  172. */ 
  173. ,_getEvent:function(){ 
  174. return window.event || arguments.callee.caller.arguments[0]; 
  175. } 
  176. } 
  177. })() 
  178. /////////////////////// 
  179. function init(){ 
  180. DragUtil.regist("WindowId","titleId") 
  181. DragUtil.regist("WindowId2","titleId2") 
  182. }  
  183. </script> 
  184. </HEAD> 
  185. <BODY onload="init()"> 
  186. <span id="qmdialog_container"><div 
  187. style="z-index: 1120; position: absolute; width: 447px; height: 163px; opacity: 1; left: 514px; top: 124px; margin-top: 0pt;" 
  188. class="" id="WindowId" qmanimation_play="|undefined"> 
  189. <div class="tipbg"> 
  190. <div style="background: #DDD;" class="opashowOuter qmpanel_shadow" 
  191. id="QMconfirm___opashow_"> 
  192. <table cellspacing="0" cellpadding="0" 
  193. style="width: 447px; height: 163px;background: white;" 
  194. class="bd_upload"> 
  195. <tbody> 
  196. <tr> 
  197. <td 
  198. style="height: 28px; border: none; background-image: none; cursor: move; overflow: hidden;" 
  199. class="editor_dialog_titlebar fdbody" 
  200. id="QMconfirm___title_td_"><div 
  201. id="QMconfirm___title_div_" 
  202. style="cursor: default; float: right; width: 40px; border: none; background-image: none;" 
  203. class="fdbody"> 
  204. <div onmouseout="this.className='editor_close';" 
  205. onmouseover="this.className='editor_close_mover';" 
  206. class="editor_close" id="QMconfirm___closebtn2_"> 
  207. <img height="12" width="12" ondragstart="return false;" src="http://www.vevb.com/jscss/demoimg/201109/ico_closetip.gif"> 
  208. </div> 
  209. </div> 
  210. <div id="titleId" class="editor_dialog_title">删除确认</div> 
  211. </td> 
  212. </tr> 
  213. <tr> 
  214. <td valign="top" 
  215. style="height: 131px; border: medium none; visibility: visible;" 
  216. class="editor_dialog_content " id="QMconfirm___content_"><div 
  217. class="mailinfo" 
  218. style="border: none; height: 100%; display: inline;"> 
  219. <div class=""> 
  220. <div class="cnfx_content"> 
  221. <img align="absmiddle" 
  222. style="float: left; margin: 5px 10px 0; display: block;" 
  223. src="http://www.vevb.com/jscss/demoimg/201109/ico_question.gif"> 
  224. <table style="width: 350px; height: 80px;"> 
  225. <tbody> 
  226. <tr> 
  227. <td style="vertical-align: top;"><div class="b_size" 
  228. style="padding-top: 10px; word-break: break-all; line-height: 150%;"> 
  229. <div>彻底删除后邮件将无法恢复,您确定要删除吗?</div> 
  230. </div></td></tr></tbody> 
  231. </table> 
  232. </div> 
  233. <div style="display: none;" class="cnfx_status"> 
  234. <input type="checkbox" id="QMconfirm__recordstatus"><label for="QMconfirm__recordstatus"></label> 
  235. </div> 
  236. <div class="cnfx_btn"> 
  237. <input type="button" value="确定" id="QMconfirm__confirm" class="wd2 btn"><input type="button" value="取消" style="display: ;" id="QMconfirm__cancel" class="wd2 btn"><input type="button" value="" style="display: none;" id="QMconfirm__never" class="wd2 btn"> 
  238. </div> 
  239. </div> 
  240. </div> 
  241. </td> 
  242. </tr> 
  243. </tbody> 
  244. </table> 
  245. </div> 
  246. </div> 
  247. </div> 
  248. </span> 
  249. <span id="qmdialog_container"><div 
  250. style="z-index: 1120; position: absolute; width: 447px; height: 163px; opacity: 1; left: 514px; top: 324px; margin-top: 0pt;" 
  251. class="" id="WindowId2" qmanimation_play="|undefined"> 
  252. <div class="tipbg"> 
  253. <div style="background: #DDD;" class="opashowOuter qmpanel_shadow" id="QMconfirm___opashow_"> 
  254. <table cellspacing="0" cellpadding="0" style="width: 447px; height: 163px;background: white;" class="bd_upload"> 
  255. <tbody> 
  256. <tr> 
  257. <td style="height: 28px; border: none; background-image: none; cursor: move; overflow: hidden;" class="editor_dialog_titlebar fdbody" id="QMconfirm___title_td_"><div id="QMconfirm___title_div_" style="cursor: default; float: right; width: 40px; border: none; background-image:none;" class="fdbody"> 
  258. <div onmouseout="this.className='editor_close';" onmouseover="this.className='editor_close_mover';" class="editor_close" id="QMconfirm___closebtn2_"> 
  259. <img height="12" width="12" ondragstart="return false;" src="http://www.vevb.com/jscss/demoimg/201109/ico_closetip.gif"> 
  260. </div> 
  261. </div> 
  262. <div id="titleId2" class="editor_dialog_title">删除确认</div> 
  263. </td> 
  264. </tr> 
  265. <tr> 
  266. <td valign="top" style="height: 131px; border: medium none; visibility: visible;" class="editor_dialog_content " id="QMconfirm___content_"><div class="mailinfo" style="border: none; height: 100%; display: inline;"> 
  267. <div class=""> 
  268. <div class="cnfx_content"> 
  269. <img align="absmiddle" 
  270. style="float: left; margin: 5px 10px 0; display:none;" src="http://www.vevb.com/jscss/demoimg/201109/ico_question.gif"> 
  271. <table style="width: 350px; height: 80px;"> 
  272. <tbody> 
  273. <tr> 
  274. <td style="vertical-align: top;"><div class="b_size" style="padding-top: 10px; word-break: break-all; line-height: 150%;"> 
  275. <div>彻底删除 
  276.  
  277.  
  278. 后邮件将无法恢复,您确定要删除吗?</div> 
  279. </div> 
  280. </td> 
  281. </tr> 
  282. </tbody> 
  283. </table> 
  284. </div> 
  285. <div style="display: none;" class="cnfx_status"> 
  286. <input type="checkbox" id="QMconfirm__recordstatus"><label for="QMconfirm__recordstatus"></label> 
  287. </div> 
  288. <div class="cnfx_btn"> 
  289. <input type="button" value="确定" id="QMconfirm__confirm" class="wd2 btn"><input type="button" value="取消" style="display: ;" id="QMconfirm__cancel" class="wd2btn"><input 
  290. type="button" value="" style="display: none;" 
  291. id="QMconfirm__never" class="wd2 btn"> 
  292. </div> 
  293. </div> 
  294. </div> 
  295. </td> 
  296. </tr> 
  297. </tbody> 
  298. </table> 
  299. </div> 
  300. </div> 
  301. </div> 
  302. </span>  
  303. </BODY> 
  304. </HTML> 



以上所述就是本文的全部内容了,希望大家能够喜欢。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选