纯粹是为了打发时间,手写了一个JS的 alert控件。
代码如下:
");//set property error!
}
}
}
return component;
}
alertObj.show = function() {
if(!this.isExist){
this.isExist = true;
var bodyObj = document.body;
bodyObj.style.zIndex = -1;
bodyObj.style.background = "#999999";
var divObj = this.createComponent("div",this.generalSet);
var txtObj = this.createComponent("p",this.txtSet);
txtObj.innerHTML = arguments[0];
var btnObj = this.createComponent("button",this.btnSet);
btnObj.innerHTML = this.btnSet.innerHTML;
btnObj.onclick = function() {
bodyObj.style.zIndex=0;
bodyObj.style.background="";
bodyObj.removeChild(divObj);
if(alertObj.isExist){
alertObj.isExist = false;
}
}
divObj.appendChild(txtObj);
divObj.appendChild(btnObj);
bodyObj.appendChild(divObj);
}
}
function show(s) {
alertObj.show(s);
}