在HTML加上
<script src=alert.js></script>
<script>alert("自定义的样式。")</script>
alert.js内容
window.alert = function(txt)
{
var shield = document.createElement("DIV");
shield.id = "shield";
shield.style.position = "absolute";
shield.style.left = "0px";
shield.style.top = "0px";
shield.style.width = "1003px";
shield.style.height = document.body.scrollHeight+"px";
//shield.style.background = "#000000";
shield.style.textAlign = "center";
shield.style.zIndex = "10000";
//shield.style.filter = "alpha(opacity=6)";
var alertFram = document.createElement("DIV");
alertFram.id="alertFram";
alertFram.style.position = "absolute";
alertFram.style.zIndex = "10001";
alertFram.style.left="310px";
alertFram.style.top="170px";
strHtml="<iframe style='position:absolute;left:0;top:0;width:100%;height:100%;z-index:-1;scrolling:no;' frameborder='0'></iframe>"
strHtml+='<div id="new" align="center" style="filter: progid:DXImageTransform.Microsoft.Shadow(color=#333333,direction=130,strength=6);position:absolute;cursor:move" οnmοusedοwn=mousedown("new");>'
strHtml+='<table width="350" border="0" cellpadding="0" cellspacing="0">'
strHtml+=' <tr>'
strHtml+=' <td width="9" align="left" background="/jsimg/a2.gif"><img src="/jsimg/a1.gif" width="9" height="29" /></td>'
strHtml+=' <td width="417" background="/jsimg/a2.gif"> <font color=#FFFFFF>中国DJ171音乐娱乐网 WWW.DMC.CN</font></td>'
strHtml+=' <td width="21" background="/jsimg/a2.gif">'
strHtml+=' <img src="/jsimg/close.gif" width="21" height="21" οnmοusemοve=this.src="/jsimg/m.gif" οnmοusedοwn=this.src="/jsimg/d.gif" οnmοuseοut=this.src="/jsimg/close.gif" οnclick="remove();" style="cursor:hand" />'
strHtml+=' </td>'
strHtml+=' <td width="9" align="right" background="/jsimg/a2.gif"><img src="/jsimg/a3.gif" width="9" height="29" /></td>'
strHtml+=' </tr>'
strHtml+=' <tr>'
strHtml+=' <td background="/jsimg/a4.gif"><img src="/jsimg/a4.gif" width="9" height="94" /></td>'
strHtml+=' <td colspan="2" valign="top" bgcolor="#FFFFFF">'+txt+'</td>'
strHtml+=' <td background="/jsimg/a5.gif"></td>'
strHtml+=' </tr>'
strHtml+=' <tr>'
strHtml+=' <td><img src="/jsimg/a6.gif" width="9" height="15" /></td>'
strHtml+=' <td colspan="2" background="/jsimg/a7.gif"></td>'
strHtml+=' <td background="/jsimg/a8.gif"></td>'
strHtml+=' </tr>'
strHtml+='</table>'
strHtml+='</div>'
alertFram.innerHTML = strHtml;
document.body.appendChild(alertFram);
document.body.appendChild(shield);
var c = 0;
this.doAlpha = function(){
if (c++ > 20){clearInterval(ad);return 0;}
shield.style.filter = "alpha(opacity="+c+");";
}
this.remove=function(){
alertFram.innerHTML="";
shield.style.filter = "";
shield.id = "";
shield.style.position = "";
shield.style.left = "";
shield.style.top = "";
shield.style.width = "";
shield.style.height ="";
shield.style.background = "";
shield.style.textAlign = "";
shield.style.zIndex = "";
shield.style.filter = "";
alertFram.id="";
alertFram.style.position = "";
alertFram.style.left = "";
alertFram.style.top = "";
alertFram.style.marginLeft = "";
alertFram.style.marginTop = "";
alertFram.style.width = "";
alertFram.style.height = "";
alertFram.style.background = "";
alertFram.style.textAlign = "";
alertFram.style.lineHeight = "";
alertFram.style.zIndex = "";
document.body.onselectstart = function(){return true;};
}
var ad = setInterval("doAlpha()",5);
alertFram.focus();
document.body.onselectstart = function(){return false;};
}
var object = null;
var newobject = null;
var element = null;
var moveX, moveY;
document.onmousemove = mousemove;
document.onmouseup = mouseup;
/* 鼠标托动 */
function mousedown(para)
{
object = document.getElementById(para);
moveX = object.style.pixelLeft - event.clientX;
moveY = object.style.pixelTop - event.clientY;
}
/* 开始托动 */
function mousemove()
{
if(object != null){
object.style.left = moveX + event.clientX;
object.style.top = moveY + event.clientY;
event.returnValue = false;
}
}
/* 释放对象 */
function mouseup()
{
if(object != null){
object = null;
}
if(newobject != null){
newobject = null;
}
}
/* 改变大小 */
function cursordown(para)
{
newobject = document.getElementById(para);
}
/* 开始改变 */
function cursormove()
{
var xMinWidth = 10, xMinHeight = 30;
var xWidth = 0, xHeight = 0;
if(newobject != null){
xWidth = Math.max(xMinWidth, event.clientX - newobject.style.left.replace('px',''));
xHeight = Math.max(xMinHeight, event.clientY - newobject.style.top.replace('px',''));
newobject.style.width = xWidth + xMinWidth + 'px';
newobject.style.height = xHeight - xMinHeight + 'px';
event.returnValue = false;