1
<input type="button" value="点击这里" onclick="sAlert('测试效果<br>还可以直接书写HTML代码 <br>© 2006');" />
2
3
<script type="text/javascript" language="javascript">
4
//Author:Daviv
5
//Blog:http://blog.163.com/jxdawei
6
//Date:2006-10-28
7
//Email:jxdawei@gmail.com
8
function sAlert(str){
9
var msgw,msgh,bordercolor;
10
msgw=400;//提示窗口的宽度
11
msgh=100;//提示窗口的高度
12
bordercolor="#336699";//提示窗口的边框颜色
13
titlecolor="#99CCFF";//提示窗口的标题颜色
14
15
var sWidth,sHeight;
16
sWidth=document.body.offsetWidth;
17
sHeight=document.body.offsetHeight;
18
19
20
var bgObj=document.createElement("div");
21
bgObj.setAttribute('id','bgDiv');
22
bgObj.style.position="absolute";
23
bgObj.style.top="0";
24
bgObj.style.background="#777";
25
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
26
bgObj.style.opacity="0.6";
27
bgObj.style.left="0";
28
bgObj.style.width=sWidth + "px";
29
bgObj.style.height=sHeight + "px";
30
document.body.appendChild(bgObj);
31
var msgObj=document.createElement("div")
32
msgObj.setAttribute("id","msgDiv");
33
msgObj.setAttribute("align","center");
34
msgObj.style.position="absolute";
35
msgObj.style.background="white";
36
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
37
msgObj.style.border="1px solid " + bordercolor;
38
msgObj.style.width=msgw + "px";
39
msgObj.style.height=msgh + "px";
40
msgObj.style.top=(document.documentElement.scrollTop + (sHeight-msgh)/2) + "px";
41
msgObj.style.left=(sWidth-msgw)/2 + "px";
42
var title=document.createElement("h4");
43
title.setAttribute("id","msgTitle");
44
title.setAttribute("align","right");
45
title.style.margin="0";
46
title.style.padding="3px";
47
title.style.background=bordercolor;
48
title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
49
title.style.opacity="0.75";
50
title.style.border="1px solid " + bordercolor;
51
title.style.height="18px";
52
title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
53
title.style.color="white";
54
title.style.cursor="pointer";
55
title.innerHTML="关闭";
56
title.onclick=function(){
57
document.body.removeChild(bgObj);
58
document.getElementById("msgDiv").removeChild(title);
59
document.body.removeChild(msgObj);
60
}
61
document.body.appendChild(msgObj);
62
document.getElementById("msgDiv").appendChild(title);
63
var txt=document.createElement("p");
64
txt.style.margin="1em 0"
65
txt.setAttribute("id","msgTxt");
66
txt.innerHTML=str;
67
document.getElementById("msgDiv").appendChild(txt);
68
}
69
</script>
70
<input type="button" value="点击这里" onclick="sAlert('测试效果<br>还可以直接书写HTML代码 <br>© 2006');" /> 2
3
<script type="text/javascript" language="javascript"> 4
//Author:Daviv 5
//Blog:http://blog.163.com/jxdawei 6
//Date:2006-10-28 7
//Email:jxdawei@gmail.com 8
function sAlert(str){ 9
var msgw,msgh,bordercolor; 10
msgw=400;//提示窗口的宽度 11
msgh=100;//提示窗口的高度 12
bordercolor="#336699";//提示窗口的边框颜色 13
titlecolor="#99CCFF";//提示窗口的标题颜色 14
15
var sWidth,sHeight; 16
sWidth=document.body.offsetWidth; 17
sHeight=document.body.offsetHeight; 18
19
20
var bgObj=document.createElement("div"); 21
bgObj.setAttribute('id','bgDiv'); 22
bgObj.style.position="absolute"; 23
bgObj.style.top="0"; 24
bgObj.style.background="#777"; 25
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 26
bgObj.style.opacity="0.6"; 27
bgObj.style.left="0"; 28
bgObj.style.width=sWidth + "px"; 29
bgObj.style.height=sHeight + "px"; 30
document.body.appendChild(bgObj); 31
var msgObj=document.createElement("div") 32
msgObj.setAttribute("id","msgDiv"); 33
msgObj.setAttribute("align","center"); 34
msgObj.style.position="absolute"; 35
msgObj.style.background="white"; 36
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 37
msgObj.style.border="1px solid " + bordercolor; 38
msgObj.style.width=msgw + "px"; 39
msgObj.style.height=msgh + "px"; 40
msgObj.style.top=(document.documentElement.scrollTop + (sHeight-msgh)/2) + "px"; 41
msgObj.style.left=(sWidth-msgw)/2 + "px"; 42
var title=document.createElement("h4"); 43
title.setAttribute("id","msgTitle"); 44
title.setAttribute("align","right"); 45
title.style.margin="0"; 46
title.style.padding="3px"; 47
title.style.background=bordercolor; 48
title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 49
title.style.opacity="0.75"; 50
title.style.border="1px solid " + bordercolor; 51
title.style.height="18px"; 52
title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; 53
title.style.color="white"; 54
title.style.cursor="pointer"; 55
title.innerHTML="关闭"; 56
title.onclick=function(){ 57
document.body.removeChild(bgObj); 58
document.getElementById("msgDiv").removeChild(title); 59
document.body.removeChild(msgObj); 60
} 61
document.body.appendChild(msgObj); 62
document.getElementById("msgDiv").appendChild(title); 63
var txt=document.createElement("p"); 64
txt.style.margin="1em 0" 65
txt.setAttribute("id","msgTxt"); 66
txt.innerHTML=str; 67
document.getElementById("msgDiv").appendChild(txt); 68
} 69
</script> 70



title.onclick
浙公网安备 33010602011771号