js的alert太丑,看网易的不错,仿做了个,不过没写拖动,感觉也没必要,反正就是提示下信息而已
<script language="javascript">
createEl = function(t, a, y, x) {
var e = document.createElement(t);
if (a) {
for (var k in a) {
if (k == 'class') e.className = a[k];
else if (k == 'id') e.id = a[k];
else e.setAttribute(k, a[k]);
}
}
if (y) { for (var k in y) e.style[k] = y[k]; }
if (x) { e.appendChild(document.createTextNode(x)); }
return e;
}
function show(){
var newElement = createEl('div',
{'className': 'msgBox', id: 'msgBox', name: 'msgBox'},
{position:'absolute',top:'100px',left:'200px'});
newElement.innerHTML="<p class=msgBoxTitleBar><iframe style=/"position:absolute;left:0;top:0;width:100%;height:100%;z-index:-1;display:none;/" frameborder=/"0/"></iframe><span > 系统提示</span>"+
"<span class=msgBoxCloseIco><img src=images/select_right.gif height=16 width=16 οnclick=/"hide()/"/></span></p><p class=msgBoxContentBar><span ><img src=images/fisheye_2.png width=30 height=30 /></span>"+
"<span >this is content!!!!!!!</span></p><p class=msgBoxButtonBar align=center><span><input type=button value=确定 οnclick=/"hide()/" /></span></p></p>";
document.body.appendChild(newElement);
}
function hide(){
var nE= document.getElementById('msgBox');
if (nE!==undefined&&nE!==null)
document.body.removeChild(nE);
}
</script>
<style type="text/css">
#msgBox{width:350px; height:150px; border:1px solid #003366; background-image:url(zd_msgBox_bg.gif); background-repeat:repeat-x;}
.msgBoxTitleBar{height:20px; position:relative; top:0px; left:0px; margin:2px; font-size:12px; padding:3px 0px 0px 5px;}
.msgBoxCloseIco{float:right;display:inline; position:absolute;top:0px; right:0px;}
.msgBoxContentBar{position:relative; top:0px; left:0px; padding:20px 20px 0px;; height:60px; margin:0px;}
.msgBoxButtonBar{position:relative; top:0px; left:0px;height:30px;margin:5px; padding:3px;}
</style>
show()没写参数,可以将参数传进来,替换要显示的内容.不过写INNERHTML太麻烦了,