How to change the alert style of js, such as background color _ javascript skills

Source: Internet
Author: User
How to change the alert style of js, for example, the background color and background transparency in the pop-up dialog box. Below are some examples for interested users to learn. 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 ";
// The background color in the pop-up dialog box
Shield. style. background = "# fff ";
Shield. style. textAlign = "center ";
Shield. style. zIndex = "25 ";
// Valid for background transparent IE
// 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 = "pixel PX ";
AlertFram. style. height = "150px ";
AlertFram. style. background = "# ff0000 ";
AlertFram. style. textAlign = "center ";
AlertFram. style. lineHeight = "150px ";
AlertFram. style. zIndex = "300 ";
StrHtml ="

    \ N ";
    StrHtml + ="
  • [Custom prompt]
  • \ 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 ;};
}


Effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.