JS使用alert如何實(shí)現(xiàn)一個(gè)彈框效果-創(chuàng)新互聯(lián)

JS使用alert如何實(shí)現(xiàn)一個(gè)彈框效果?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。

網(wǎng)站的建設(shè)創(chuàng)新互聯(lián)公司專(zhuān)注網(wǎng)站定制,經(jīng)驗(yàn)豐富,不做模板,主營(yíng)網(wǎng)站定制開(kāi)發(fā).小程序定制開(kāi)發(fā),H5頁(yè)面制作!給你煥然一新的設(shè)計(jì)體驗(yàn)!已為成都食品包裝袋等企業(yè)提供專(zhuān)業(yè)服務(wù)。

具體內(nèi)容如下

先上圖:

JS使用alert如何實(shí)現(xiàn)一個(gè)彈框效果

alert.js代碼:


var myAlert = {
 alertbox : function(alertContent){
 var windowWidth = window.innerWidth; 
 windowHeight = window.innerHeight; 
 alertContainer = document.createElement("div");
 alertContainer.id = "myAlertBox";
 alertContainer.style.cssText="position:absolute;left:0px;top:0px;width:100%;z-index:9999;";
 alertContainer.style.height = windowHeight+"px"; 
 alertOpacity = document.createElement("div");
 alertOpacity.style.cssText="position:absolute;left:0px;top:0px;width:100%;background:#000;opacity:0.5;z-index:9999;";
 alertOpacity.style.height = windowHeight+"px"; 
 alertContainer.appendChild(alertOpacity)
 alertMainBox = document.createElement("div");
 alertMainBox.style.cssText="position:absolute;width:200px;height:200px;line-height:200px;text-align:center;background:green;z-index:10000;"
 alertMainBoxLeft = (windowWidth-200)/2;
 alertMainBoxTop = (windowHeight-200)/2;
 alertMainBox.style.left = alertMainBoxLeft+"px";
 alertMainBox.style.top = alertMainBoxTop+"px";
 alertMainBox.innerHTML = alertContent;
 alertContainer.appendChild(alertMainBox);
 alertClose = document.createElement("div");
 alertClose.id = "closeBox";
 alertClose.style.cssText = "position:absolute;right:0px;top:0px;width:30px;height:30px;background:red;cursor:pointer";
 alertMainBox.appendChild(alertClose);
 document.body.appendChild(alertContainer);
 closeButton = document.getElementById("closeBox");
 console.log(closeButton)
 closeButton.onclick = function(){
 document.body.removeChild(document.getElementById("myAlertBox"));
 }
 }
}

文章題目:JS使用alert如何實(shí)現(xiàn)一個(gè)彈框效果-創(chuàng)新互聯(lián)
標(biāo)題路徑:http://muchs.cn/article0/eieio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司網(wǎng)站維護(hù)、定制開(kāi)發(fā)面包屑導(dǎo)航、品牌網(wǎng)站設(shè)計(jì)動(dòng)態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作