急!框架中设置div的宽高,急!!!

quxiuer 2008-07-31 08:14:04
页面a.jsp中包含框架frame
框架中包含页面b.jsp
想在b.jsp中有一个div想把div的宽高设置成a.jsp的宽和高
已经得到了宽和高 但是div显示的大小是frame的大小
请问怎么办
...全文
663 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
quxiuer 2008-08-01
  • 打赏
  • 举报
回复
1.js文件


<script type="text/javascript">
function $(_sId) {
return document.getElementById(_sId);
}
function showDiv(_sID,event) {
var arrySize = getPageSize();
var oObj = $(_sID);
//创建一个DIV,改名为 overlay 这个是透明的层
var oDiv =document.createElement("div");
oDiv.id = "overlay";
document.body.appendChild(oDiv);
var overlay = $("overlay");
overlay.style.height = arrySize[1];
overlay.style.width = arrySize[0];
if(event == null) {
if(oObj.style.left == "") {
oObj.style.left = arrySize[0] / 2 - 150 ;
}
if(oObj.style.top == "") {
oObj.style.top = arrySize[0] / 2;
}
} else {
var iEvent= window.event ? window.event : event;
oObj.style.left = arrySize[0] / 2 - 150 ; // iEvent.clientX;
oObj.style.top = arrySize[1] / 2 - 150 ;// iEvent.clientY;
}
document.getElementById("floatDiv").style.top=document.body.scrollTop+(document.body.clientHeight-document.getElementById("floatDiv").offsetHeight)/1;
document.getElementById("floatDiv").style.left=document.body.scrollLeft+(document.body.clientWidth-document.getElementById("floatDiv").offsetWidth)/2;
oObj.style.display = "block";

overlay.style.display = "block";
overlay.style.zindex = oObj.style.zindex - 1;
}
function closeDiv(_sID) {
var oObj = $(_sID);
var overlay = $("overlay");
if(overlay != null) {
overlay.outerHTML = "";
}
oObj.style.display = "none";
document.forms["sendInviteEmailForm"].submit();
}
//取得页面大小
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}

var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}

// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}

// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}


arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
</script>

2.框架页面
<iframe id="watiLinkManFrame" src="viewWaitLinkMan.do" style="zIndex:99" marginwidth="0" marginheight="0" frameborder="0" width="882" height="430"
allowtransparency="allowTransparency"></iframe>

3.包含页面
<style>
body{
background:#FFF;
font-size:12px;
font-family:宋体;
}
#overlay{
position: absolute;
top: 0;
left: 0;
z-index: 99;
width: 100%;
height: 500px;
background-color: #000;
filter:alpha(opacity=40);
-moz-opacity: 0.6;
opacity: 0.6;
}

.floatDiv{
padding:0 0 0 0;
position:absolute;
width:300px;
margin:0 0 0 0;
z-index:100;
border:1px solid #DADADA;
background:#FFF; padding:1px;
}
</style>

<body>

<div id="main" style="position:relative;">
<table width="864" border="0" align="center" cellpadding="0" cellspacing="10">
<tr>
<td align="center" bgcolor="F3F3F3"><a href="#" class="menubar" onClick="showDiv('floatDiv',event);重新发送</a></td>
</tr>
</table>
</div>
<div id="floatDiv" class="floatDiv" style="display:none;"></div>
</body>
mydeman 2008-08-01
  • 打赏
  • 举报
回复
是不是因为没有设置div的scrollbar,所以看起来显示还是那么大,其实宽和高已经变了?
xahaxi 2008-08-01
  • 打赏
  • 举报
回复
宽可以设100%,高不行!
hbhbhbhbhb1021 2008-07-31
  • 打赏
  • 举报
回复
frame的大小也要设成100%。
还是需要具体的代码才知道问题出在什么地方

87,899

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧