最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
js 自定义对话框
时间:2022-11-14 22:03:43 编辑:袖梨 来源:一聚教程网
js 自定义对话框
test.htm
open
open
MessageBox.css
#MessageBoxBackground{
background-color:#eeeeee;position:absolute;
left:0px;top:0px;
filter:alpha(opacity=70);
}
#MessageBox{
/* left:300px;
*/
background-color:#eeeeee;
z-index:10000;
position:absolute;
padding:0px;
border-left:2px solid #ffffff;
border-top:2px solid #ffffff;
border-bottom:2px solid gray;
border-right:2px solid gray;
}
#MessageBoxTop{
background-color:#0066FF;
}
#MessageBoxTitle{
font-size:14pt;
font-family:"华文新魏";
color:#dddddd;
}
#MessageBox_CloseButton{
}
#MessageBoxBody, #MessageBoxBody td{
background-color:#eeeeee;
height:100%;
padding:4px;
font-size:9pt;
}
#MessageBox_CloseButton a:link,#MessageBox_CloseButton a:visited{
text-decoration:none;
color:#CCCCCC;
}
MessageBox.js
function $(strid){
return document.getElementById(strid);
}
function MessageBox_createDivs(){
document.write('
');
document.write('
');
document.write('
document.write("
");document.write('
'); document.write(' 提示: ');document.write(' | '); document.write(' × ');document.write(' |
document.write('
示例内容,请调用相关方法!');
document.write("
");document.write("
document.write("
document.write("
");
document.write("
");document.write("
}
function MessageBox_setSize(){
// for(i=0;i<100;i++){ document.write("
"); }
var bg=document.getElementById("MessageBoxBackground");
var scroll_top=document.body.scrollTop;
var scroll_left=document.body.scrollLeft;
var scroll_width=document.body.offsetWidth;
var scroll_height=document.body.offsetHeight;
bg.style.px";
bg.style.px";
$("MessageBoxBackground").style.display='none';
$("MessageBox").style.display='none';
}
function MessageBox_init(){
MessageBox_createDivs();
MessageBox_setSize();
}
function MessageBox_show(){
var scroll_top=document.body.scrollTop;
var scroll_left=document.body.scrollLeft;
var scroll_width=document.body.offsetWidth;
var scroll_height=document.body.offsetHeight;
var messageBox_MessageBox').style.width;
var messageBox_left=(scroll_width-400)/2;
//alert(scroll_width+","+messageBox_width+"");
document.getElementById('MessageBoxBackground').style.display='';
document.getElementById('MessageBox').style.display='';
$("MessageBox").style.left=messageBox_left+"px";
}
function MessageBox_hide(){
document.getElementById('MessageBoxBackground').style.display='none';
document.getElementById('MessageBox').style.display='none';
}
function MessageBox_setTitle(title){
$("MessageBoxTitle").innerHTML=title;
}
function MessageBox_setBody(body){
$("MessageBoxBody").innerHTML=body;
}
function MessageBox_addChild(strChild){
var objChild=$(strChild);
var obj=$("MessageBoxBody");
obj.innerHTML=objChild.innerHTML;
//obj.appendChild(objChild);
}
function MessageBox_showDialog(title,div_id){
MessageBox_setTitle(title);
MessageBox_addChild(div_id);
MessageBox_show();
}
function MessageBox_showDialogText(title,message){
MessageBox_setTitle(title);
MessageBox_setBody(message);
MessageBox_show();
}
MessageBox_init();
下面是一个一体化的:
MsgBack.htm
open
open