Home  >  Article  >  Web Front-end  >  How to change the alert style of js such as background color_javascript skills

How to change the alert style of js such as background color_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:03:041672browse
Copy code The code is as follows:

window.alert = function(str)
{
var shield = document.createElement("DIV");
shield.id = "shield";
shield.style.position = "absolute";
shield.style.left = "0px";
shield.style.top = "0px";
shield.style.width = "100%";
shield.style.height = document.body.scrollHeight "px";
//Pop up The background color of the dialog box
shield.style.background = "#fff";
shield.style.textAlign = "center";
shield.style.zIndex = "25";
/ /Background transparent IE valid
//shield.style.filter = "alpha(opacity=0)";
var alertFram = document.createElement("DIV");
alertFram.id="alertFram" ;
alertFram.style.position = "absolute";
alertFram.style.left = "50%";
alertFram.style.top = "50%";
alertFram.style.marginLeft = "-225px";
alertFram.style.marginTop = "-75px";
alertFram.style.width = "450px";
alertFram.style.height = "150px";
alertFram .style.background = "#ff0000";
alertFram.style.textAlign = "center";
alertFram.style.lineHeight = "150px";
alertFram.style.zIndex = "300";
strHtml = "
    n";
    strHtml = "
  • [Custom tip ]
  • n";
    strHtml = "
  • " str "
  • n";
    strHtml = "
  • n";
    strHtml = "
n";
alertFram.innerHTML = strHtml;
document.body.appendChild(alertFram);
document. body.appendChild(shield);
var ad = setInterval("doAlpha()",5);
this.doOk = function(){
alertFram.style.display = "none";
shield.style.display = "none";
}
alertFram.focus();
document.body.onselectstart = function(){return false;};
}

The effect is as shown in the picture
How to change the alert style of js such as background color_javascript skills
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn