Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> rewrite alert </title>
<Link href = "css/style.css" rel = "stylesheet"/>
<Script type = "text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"> </script>
<Script type = "text/javascript">
Var showAlert = function (msg ){
JAlert (msg, "prompt! ");
}
Window. alert = showAlert;
$. Alerts = {
VerticalOffset:-75, horizontalOffset: 0, repositionOnResize: true, overlayOpacity :. 01, overlayColor: '# fff', draggable: true, okButton:' OK ', cancelButton: 'cancel', dialogClass: null, alert: function (message, title, callback ){
If (title = null) title = 'alert ';
$. Alerts. _ show (title, message, null, 'alert ', function (result ){
If (callback) callback (result)
})
}
, _ Show: function (title, msg, value, type, callback ){
$. Alerts. _ hide ();
$. Alerts. _ overlay ('show ');
$ ("BODY "). append ('<div id = "popup_container">' + '
If ($. alerts. dialogClass) $ ("# popup_container"). addClass ($. alerts. dialogClass );
Var pos = ($. browser. msie & parseInt ($. browser. version) <= 6 )? 'Absolute ': 'fixed ';
$ ("# Popup_container" ).css ({
Position: pos, zIndex: 99999, padding: 0, margin: 0
});
$ ("# Popup_title"). text (title );
$ ("# Popup_content"). addClass (type );
$ ("# Popup_message"). text (msg );
$ ("# Popup_message" ).html ($ ("# popup_message"). text (). replace (/\ n/g, '<br/> '));
$ ("# Popup_container" ).css ({
MinWidth: $ ("# popup_container"). outerWidth (), maxWidth: $ ("# popup_container"). outerWidth ()
});
$. Alerts. _ reposition ();
$. Alerts. _ maintainPosition (true );
Switch (type ){
Case 'alert ': $ ("# popup_message "). after ('<div id = "popup_panel"> <input type = "button" value = "' + $. alerts. okButton + '"id =" popup_ OK "/> </div> ');
$ ("# Popup_ OK"). click (function (){
$. Alerts. _ hide ();
Callback (true)
});
$ ("# Popup_ OK"). focus (). keypress (function (e ){
If (e. keyCode = 13 | e. keyCode = 27) $ ("# popup_ OK"). trigger ('click ')
});
Break
};
If ($. alerts. draggable ){
Try {
$ ("# Popup_container"). draggable ({
Handle: $ ("# popup_title ")
});
$ ("# Popup_title" ).css ({
Cursor: 'move'
})
}
Catch (e ){}
}
}
, _ Hide: function (){
$ ("# Popup_container"). remove ();
$. Alerts. _ overlay ('hide ');
$. Alerts. _ maintainPosition (false)
}
, _ Overlay: function (status ){
Switch (status ){
Case 'show': $. alerts. _ overlay ('hide ');
$ ("BODY"). append ('<div id = "popup_overlay"> </div> ');
$ ("# Popup_overlay" ).css ({
Position: 'absolute ', zIndex: 99998, top: '0px', left: '0px ', width: '20180101', height: $ (document ). height (), background: $. alerts. overlayColor, opacity: $. alerts. overlayOpacity
});
Break;
Case 'hide ': $ ("# popup_overlay"). remove ();
Break
}
}
, _ Reposition: function (){
Var top = ($ (window). height ()/2)-($ ("# popup_container"). outerHeight ()/2) + $. alerts. verticalOffset;
Var left = ($ (window). width ()/2)-($ ("# popup_container"). outerWidth ()/2) + $. alerts. horizontalOffset;
If (top <0) top = 0;
If (left <0) left = 0;
If ($. browser. msie & parseInt ($. browser. version) <= 6) top = top + $ (window). scrollTop ();
$ ("# Popup_container" ).css ({
Top: top + 'px ', left: left + 'px'
});
$ ("# Popup_overlay"). height ($ (document). height ())
}
, _ MaintainPosition: function (status ){
If ($. alerts. repositionOnResize ){
Switch (status ){
Case true: $ (window). bind ('resize', function (){
$. Alerts. _ reposition ()
});
Break;
Case false: $ (window). unbind ('resize ');
Break
}
}
}
};
JAlert = function (message, title, callback ){
$. Alerts. alert (message, title, callback)
}
$ (Function () {alert ("hello word! ")})
</Script>
<Style>
# Popup_container {font-family: Arial, sans-serif; font-size: 12px; min-width: 300px; max-width: 600px; background: # FFF; border: solid 5px #999; color: #000;-moz-border-radius: 5px;-webkit-border-radius: 5px; border-radius: 5px ;} # popup_title {font-size: 14px; font-weight: bold; text-align: center; line-height: 1.75em; color: #666; background: # CCC url (images/title.gif) top repeat-x; border: solid 1px # FFF; border-bottom: solid 1px #999; cursor: default; padding: 0em; margin: 0em ;}# popup_content {background: 16px 16px no-repeat url (images/info.gif); padding: 1em 1.75em; margin: 0em ;}# popup_content.alert {background-image: url (images/info.gif) ;}# popup_message {padding-left: 48px ;}# popup_panel {text-align: center; margin: 1em 0em 0em 1em ;} # popup_prompt {margin :. 5em 0em ;}
</Style>
</Head>
<Body>
</Body>
</Html>