我试了试,加不加 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 这句话都没有什么影响啊,可以显示也可以隐藏奇怪. lz 把代码贴出来看看
js源码 文件名:showDiv.jsfunction openNewDiv(parentDiv,childDiv) { var m = "mask";
var thisWheight=0; var thisWwidth=0; var thisWtop=0; thisWheight=document.body.scrollHeight>document.documentElement.scrollHeight?document.body.scrollHeight:document.documentElement.scrollHeight thisWheight=document.body.scrollWidth>document.documentElement.scrollWidth?document.body.scrollWidth:document.documentElement.scrollWidth thisWtop=document.body.scrollTop>document.documentElement.scrollTop?document.body.scrollTop:document.documentElement.scrollTop
} function toCloseDiv(parentDiv,childDiv) { var newDiv=document.getElementById(childDiv); var newMask=document.getElementById(parentDiv); newDiv.style.display="none"; newMask.style.display="none"; document.body.style=="overflow:auto;"; document.body.scroll="yes";
当然不能显示滚动条啦
我通过js设置了 下 body的高度 滚动条 出来了但是又出现新问题了 设置了 body的高度后 整体页面拉伸了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 这句话都没有什么影响啊,可以显示也可以隐藏奇怪.
lz 把代码贴出来看看
var m = "mask";
var thisWheight=0;
var thisWwidth=0;
var thisWtop=0;
thisWheight=document.body.scrollHeight>document.documentElement.scrollHeight?document.body.scrollHeight:document.documentElement.scrollHeight
thisWheight=document.body.scrollWidth>document.documentElement.scrollWidth?document.body.scrollWidth:document.documentElement.scrollWidth
thisWtop=document.body.scrollTop>document.documentElement.scrollTop?document.body.scrollTop:document.documentElement.scrollTop
//切换滚动条状态
document.body.scroll="no";
// 新激活图层
var newDiv=document.getElementById(childDiv)
//var newDiv = document.createElement("div");
//newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "9999";
newDiv.style.width = "200px";
newDiv.style.height ="100px";
newDiv.style.top = (parseInt(thisWtop)+100)+ "px";
newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中
newDiv.style.background = "#EFEFEF";
newDiv.style.border = "1px solid #860001";
newDiv.style.padding = "5px";
newDiv.style.display="";
var newMask=document.getElementById(parentDiv);
newMask.style.position = "absolute";
newMask.style.zIndex = "100";
newMask.style.width = document.body.clientWidth + "px";
newMask.style.height = window.screen.availHeight + "px";
document.documentElement.style.overflow='hidden';
newMask.style.top = parseInt(thisWtop)+"px";
newMask.style.left = "0px";
newMask.style.filter = "alpha(opacity=40)";
newMask.style.opacity = "0.40";
newMask.style.display="";
return false;
}
function toCloseDiv(parentDiv,childDiv)
{
var newDiv=document.getElementById(childDiv);
var newMask=document.getElementById(parentDiv);
newDiv.style.display="none";
newMask.style.display="none";
document.body.style=="overflow:auto;";
document.body.scroll="yes";
}html文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<input type="button" name="Submit" value="按钮" onclick="toshow()" />
<div style="display:none; background:#C2E4FE" id="mytoo" ></div>
<div id="iuuu" style=" display:none;">
我就是遮照层
<input id="Button2" type="button" value="返回" onClick="toCloseDiv('mytoo','iuuu')" />
</div>
<table width="200" border="1">
<tr>
<td height="1400"><input type="button" name="Submit2" value="按钮" onclick="toshow()" /></td>
</tr>
</table>
<script src="jss/showDiv.js"></script>
<script language="javascript">
function toshow()
{ openNewDiv('mytoo','iuuu');
}
</script>
</body>
</html>