This article will introduce how to use Jquery to rewrite the windows. alert method. It has passed the test under IE8 and firefox3.0.11, and can be used by friends who like it in IE8 and firefox3.0.11.
The Code is as follows:
$. Extend ({
IncludePath :'',
Include: function (file)
{
Var files = typeof file = "string "? [File]: file;
For (var I = 0; I <files. length; I ++)
{
Var name = files [I]. replace (/^ \ s | \ s $/g ,"");
Var att = name. split ('.');
Var ext = att [att. length-1]. toLowerCase ();
Var isCSS = ext = "css ";
Var tag = isCSS? "Link": "script ";
Var attr = isCSS? "Type = 'text/css 'rel = 'stylesheet'": "language = 'javascript 'Type = 'text/javascript '";
Var link = (isCSS? "Href": "src") + "= '" + $. includePath + name + "'";
If ($ (tag + "[" + link + "]"). length = 0) document. write ("<" + tag + attr + link + "> ");
}
}
});
$. Include (['script/jquery. pbox. js', '/css/pop_win.css']);
$ (Document). ready (function ()
{
Var IsFirstAlert = true;
Var alertQueue = [];
Window. alert = showAlert;
Var palert = "";
Palert + ="
";
Palert + ="
";
Palert + ="
";
Palert + ="
TITLE <\/h3> <\/p> ";
Palert + ="
<\/P> ";
Palert + = "<\/p> ";
Palert + ="
";
Palert + = "<\/span>
";
Palert + ="
<\/P> ";
Palert + = "<\/p> ";
Palert + ="
<\/P> ";
Palert + ="
<\/P> ";
Palert + = "<\/p> ";
Palert + = "";
Palert + = "<\/p> ";
$ ("Body"). append (palert );
Function showAlert (info)
{
AlertQueue. push (info );
If (IsFirstAlert)
{
IsFirstAlert = false;
OpenAlert ();
}
}
$ ("# AlertClose"). click (function ()
{
$ ('# PAlert'). CloseDiv ()
If (alertQueue. length> 0)
{
SetTimeout (OpenAlert, 150 );
}
});
Function OpenAlert ()
{
$ ("# SpaAlertMessage" pai.html (alertQueue [0]);
AlertQueue. splice (0, 1 );
$ ("# PAlert"). OpenDiv ();
}
});
Note: The jquery plug-in referenced above for js and CSS