Js pop-up box instead of browser pop-up box _ javascript skills

Source: Internet
Author: User
The js pop-up box replaces the browser pop-up box. For more information, see. The Code is as follows:


Function fromID (id ){
Return document. getElementById (id );
}

Function show_alert (msg, type, time ){
Var layer_obj = fromID ("alert_layer ");
Var layer_text = fromID ("alert_text ");
Var line_height = (document.doc umentElement. scrollTop = 0 )? Document. body. scrollTop: document.doc umentElement. scrollTop;

Layer_text.innerHTML = msg;
With (layer_obj.style ){
ZIndex = 999;
Top = line_height-40;
Left = document. body. clientWidth/3;
Display = "block ";
Position = "absolute ";
If (type = "error "){
Background = "url (http: //" + style_domain + "/snake/index/msgbox_right_bg2.jpg )";
}
}

Layer_obj.filters [0]. opacity = "0.8"; // The transparency is 80%.

If (time = undefined) time = 3000;
Else time = time * 1000;

Var top = line_height-40;
Var speed = 1.5;
Time-= 1000;
// The control window moves down to the edge of the page
Move_down = function MoveFplogo (){
Top + = speed;
Layer_obj.style.top = top;
If (top <line_height) setTimeout ("move_down ()", 1 );
Else setTimeout ("close_alert_win ()", time );
}

Move_down ();
}

Function close_alert_win (){
Var layer_obj = fromID ("alert_layer ");
// The control window gradually disappears
If (layer_obj.filters [0]. opacity <0.02 ){
Layer_obj.style.display = "none ";
Return true;
}
Layer_obj.filters [0]. opacity-= 0.02;
SetTimeout ("close_alert_win ()", 1 );
}
Document. writeln ("filter: progid: DXImageTransform. Microsoft. BasicImage ();"> ");
Document. writeln ("");
Document. writeln ("");
Document. writeln ("");

Related Article

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.