以下是我写的js代码可以实现你的要求,应该很简单吧
//半通明遮罩
document.writeln("
");
var divGg = document.getElementById("divGg");
//弹出层
document.writeln("
");
var divAdMsg = document.getElementById("divAdMsg");
//显示打开弹出层内容
function showAdMsg()
{
if(divAdMsg)
{
divAdMsg.style.display = "";
divAdMsg.style.top = document.documentElement.scrollTop + parseInt((document.documentElement.clientHeight - divAdMsg.offsetHeight) / 2) + "px";
divAdMsg.style.left = document.documentElement.scrollLeft + parseInt((document.documentElement.clientWidth - divAdMsg.offsetWidth) / 2) + "px";
divGg.style.width = document.body.offsetWidth + "px";
if(document.body.offsetHeight < document.documentElement.scrollTop + document.documentElement.clientHeight)
divGg.style.height = document.documentElement.scrollTop + document.documentElement.clientHeight + "px";
else
divGg.style.height = document.body.offsetHeight + "px";
divGg.style.display = "";
}
}
//关闭打开弹出层内容
function closeAdMsg()
{
divAdMsg.style.display = "none";
divGg.style.display = "none";
}
showAdMsg();