这个很常见吧,触发一个事件,生成一个半透明的浮动div,大小和窗口大小一致,将窗口注册上onresize和onscroll事件,动态调整div的位置和大小就可以了
解决方案 »
- cookie
- 事件和事件句柄的区别是什么
- json数据到ext前台显示的问题
- JQuery validation engine 表单元素ajax验证失败
- 帮忙改一小段广告代码?
- 用window.open打开的子窗口在父窗口中动态创建flash(OBJECT)的问题
- [50在线等谢谢]在js 中怎么获得text中所输入的信息占有的字节byte
- 是不是在网页中支持REALPLAYER播放视频的语句怎么写》?
- 用SHOWModalDialog打开的窗口,关闭后怎么同时刷新父窗口(在线等)
- 如何让javascript读取出来的COOKIES内容显示中文?
- javascript刷新父窗口
- 如何控制背景图片?
//********* 锁屏DIV ***************************
function LockScreen(tag,title,width,height,url)
{
if (tag) //锁屏
{
var lockdiv = document.getElementById("lockscreen");
if (lockdiv!=null)
{
lockdiv.style.display = "block";
var subdiv = document.getElementById("subdialog");
if (subdiv!=null)
{
subdiv.style.display = "block";
document.getElementById("dialog1").src = url;
}
}else{
//创建新的锁屏DIV,并执行锁屏
var tabframe= document.createElement("div");
tabframe.id = "lockscreen";
tabframe.name = "lockscreen";
tabframe.style.top = '0px';
tabframe.style.left = '0px';
tabframe.style.height = '100%';
tabframe.style.width = '100%';
tabframe.style.position = "absolute";
tabframe.style.filter = "Alpha(opacity=10)";
tabframe.style.backgroundColor="#000000";
tabframe.style.zIndex = "99998";
document.body.appendChild(tabframe);
tabframe.style.display = "block";
//子DIV
var subdiv = document.createElement("div");
subdiv.id = "subdialog";
subdiv.name = "subdialog";
subdiv.style.top = Math.round((tabframe.clientHeight-height)/2);
subdiv.style.left = Math.round((tabframe.clientWidth-width)/2);
subdiv.style.height = height+'px';
subdiv.style.width = width+'px';
subdiv.style.position = "absolute";
subdiv.style.backgroundColor="red";
subdiv.style.zIndex = "99999";
subdiv.style.filter = "Alpha(opacity=100)";
subdiv.style.border = "1px";
subdiv.onmousemove = mouseMoveDialog;
subdiv.onmousedown = control_onmousedown;
subdiv.onmouseup = mouseUp;
document.body.appendChild(subdiv);
subdiv.style.display = "block";
//subdiv.onclick=UNLockScreen;
var iframe_height = height-30;
var titlewidth = width-14;
var html = "<table border='0' cellpadding='0' cellspacing='0'>"
html += "<tr><td></td><td>";
html += "<table><tr><td><font color='#FFFFFF'><b>"+title+"</b></font></td><td style='width:30px' valign='top'><img src='/images/images/close.gif' onclick='UNLockScreen();' style='cursor:hand;'></img></td></tr></table>";
html += "</td><td></td></tr>";
html += "<tr><td></td><td style='height:100px;'><iframe id='dialog1' frameborder=0 style='width:"+titlewidth+"px;height:" + iframe_height + "px' src='"+url+"'></iframe></td><td></td></tr>";
html += "<td></td><td></td><td></td>";
html += "</table>";
subdiv.innerHTML = html;
}
}else{
//解屏
var lockdiv = document.getElementById("lockscreen");
if (lockdiv!=null)
{
lockdiv.style.display = "none";
}
var subdiv = document.getElementById("subdialog");
if (subdiv!=null)
{
subdiv.style.display = "none";
}
}
}
function UNLockScreen()
{
LockScreen(false);
}//调用方法LockScreen(true,"标题",424,314,http://www.baidu.com);
//********* 锁屏DIV ***************************
function LockScreen(tag,title,width,height,url)
{
if (tag) //锁屏
{
var lockdiv = document.getElementById("lockscreen");
if (lockdiv!=null)
{
lockdiv.style.display = "block";
var subdiv = document.getElementById("subdialog");
if (subdiv!=null)
{
subdiv.style.display = "block";
document.getElementById("dialog1").src = url;
}
}else{
//创建新的锁屏DIV,并执行锁屏
var tabframe= document.createElement("div");
tabframe.id = "lockscreen";
tabframe.name = "lockscreen";
tabframe.style.top = '0px';
tabframe.style.left = '0px';
tabframe.style.height = '100%';
tabframe.style.width = '100%';
tabframe.style.position = "absolute";
tabframe.style.filter = "Alpha(opacity=10)";
tabframe.style.backgroundColor="#000000";
tabframe.style.zIndex = "99998";
document.body.appendChild(tabframe);
tabframe.style.display = "block";
//子DIV
var subdiv = document.createElement("div");
subdiv.id = "subdialog";
subdiv.name = "subdialog";
subdiv.style.top = Math.round((tabframe.clientHeight-height)/2);
subdiv.style.left = Math.round((tabframe.clientWidth-width)/2);
subdiv.style.height = height+'px';
subdiv.style.width = width+'px';
subdiv.style.position = "absolute";
subdiv.style.backgroundColor="red";
subdiv.style.zIndex = "99999";
subdiv.style.filter = "Alpha(opacity=100)";
subdiv.style.border = "1px";
subdiv.onmousemove = mouseMoveDialog;
subdiv.onmousedown = control_onmousedown;
subdiv.onmouseup = mouseUp;
document.body.appendChild(subdiv);
subdiv.style.display = "block";
//subdiv.onclick=UNLockScreen;
var iframe_height = height-30;
var titlewidth = width-14;
var html = " <table border='0' cellpadding='0' cellspacing='0'>"
html += " <tr> <td> </td> <td>";
html += " <table> <tr> <td> <font color='#FFFFFF'> <b>"+title+" </b> </font> </td> <td style='width:30px' valign='top'> <img src='/images/images/close.gif' onclick='UNLockScreen();' style='cursor:hand;'> </img> </td> </tr> </table>";
html += " </td> <td> </td> </tr>";
html += " <tr> <td> </td> <td style='height:100px;'> <iframe id='dialog1' frameborder=0 style='width:"+titlewidth+"px;height:" + iframe_height + "px' src='"+url+"'> </iframe> </td> <td> </td> </tr>";
html += " <td> </td> <td> </td> <td> </td>";
html += " </table>";
subdiv.innerHTML = html;
}
}else{
//解屏
var lockdiv = document.getElementById("lockscreen");
if (lockdiv!=null)
{
lockdiv.style.display = "none";
}
var subdiv = document.getElementById("subdialog");
if (subdiv!=null)
{
subdiv.style.display = "none";
}
}
}
function UNLockScreen()
{
LockScreen(false);
} //调用方法 LockScreen(true,"标题",424,314,http://www.baidu.com);