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

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

使用JavaScript實(shí)現(xiàn)alert的實(shí)例代碼

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

廢話不多說(shuō)了,直接給大家貼代碼了,具體代碼如下所示:

<script>   window.alert = alert;   function alert(data) {     var MainDiv = document.createElement("div"),       p = document.createElement("p"),       AllPage = document.createElement("div"),       btn = document.createElement("div"),       textNode = document.createTextNode(data ? data : ""),       btnText = document.createTextNode("確定");     // 控制樣式     css(AllPage, {       "position": "fixed",       " _position": "absolute",       " width": "100%",       "height": "100%",       "left": "0",       "top": "0",       "background": "rgba(0, 0, 0,0.5)",       "-moz-opacity": "0.5",       "filter": "alpha(opacity=50)",       "z-index": "97",     });     css(MainDiv, {       "position": "fixed",       "left": "0",       "right": "0",       "top": "30%",       "width": "14rem",       "height": "5rem",       "padding-top":"0.5rem",       "margin": "0 auto",       "background-color": "white",       "font-size": "0.75rem",       "text-align": "center",       "position": "relative",       "border-radius": "5px 5px 5px 5px",     });     css(btn, {       "background": "#de241b",       "color": "white",       "width": "6rem",       "margin-left": "4rem",       "margin-bottom":"0.25rem",       "height": "1.5rem",       "border-radius": "5px 5px 5px 5px",       "position": "absolute",       "padding-top":"0.5rem",       "bottom":"0",     })     // 內(nèi)部結(jié)構(gòu)套入     p.appendChild(textNode);     btn.appendChild(btnText);     MainDiv.appendChild(p);     MainDiv.appendChild(btn);     AllPage.appendChild(MainDiv);     // 整體顯示到頁(yè)面內(nèi)     document.getElementsByTagName("body")[0].appendChild(AllPage);     //禁止?jié)L動(dòng)     $("body").on("touchmove", function (event) {       event.preventDefault;     }, false)     // 確定綁定點(diǎn)擊事件刪除標(biāo)簽     btn.onclick = function () {       AllPage.parentNode.removeChild(AllPage);       //啟用滾動(dòng)       $("body").off("touchmove");     }   }   function css(targetObj, cssObj) {     var str = targetObj.getAttribute("style") ? targetObj.getAttribute("style") : "";     for (var i in cssObj) {       str += i + ":" + cssObj[i] + ";";     }     targetObj.style.cssText = str;   } 

以上所述是小編給大家介紹的使用JavaScript實(shí)現(xiàn)alert的實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)錯(cuò)新站長(zhǎng)站網(wǎng)站的支持!

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

圖片精選

主站蜘蛛池模板: 平乡县| 通渭县| 城固县| 略阳县| 云林县| 七台河市| 本溪| 方正县| 尖扎县| 温泉县| 石首市| 饶河县| 上思县| 驻马店市| 海口市| 漳浦县| 普定县| 永顺县| 泽州县| 蓬莱市| 涞源县| 南丹县| 阿城市| 宁津县| 泸定县| 喜德县| 方城县| 绍兴县| 柳州市| 龙门县| 余干县| 新密市| 新巴尔虎右旗| 云龙县| 彭州市| 昆明市| 芷江| 建水县| 宽城| 荔浦县| 南漳县|