人的头脑太复杂,时间过得久,有时候连自己也被自己骗了,记下来才是最真实的..
2007年1月10日 11:28
问题
       在弹出窗口时,根据窗口的内容来自动调节窗口的大小,窗口如果已经和屏幕相等大小时则出现滚动条。
解决方案
       在弹出的页面中添加一JS脚本方法win_onLoad(),在body的onload方法中引用win_onLoad(),在body中添加表,表的id取名为tbllist,窗口的大小就是这个table的大小在宽和高上分别加50。
       窗口弹出时,父窗口设定的大小如果小于500的则弹出的窗口为500,大于的则是原来大小,弹出窗口的内容如果大于本来的大小则自适应窗口的大小。

部分代码如下:

       父窗口a.html页面代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml...
<html xmlns="http://www.w3.org/1999/xht...
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<script language="javascript">
function js()
{
   window.open("b.html","b","width=100,height=100,top=100,left=100,scrollbars=yes,resizable=no,menubar=no,status=no");
}
</script>
</head>

<body>
<input type="submit" name="Submit" value="提交" onclick="js();" />
</body>
</html>

       
       子页面b.html代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml...
<html xmlns="http://www.w3.org/1999/xht...
<script language=javascript>
//
function win_onLoad(){
   var width = document.all["tblList"].offsetWidth;    
   var height = document.all["tblList"].offsetHeight;
   
   width = eval(width + 50);
   height = eval(height + 50);
   
   if (width < 500)
       width = 500;
   else if (width > screen.width)
       width = screen.width;
   
   if (height < 500)
       height = 500;
   else if (height > screen.height)
       height = screen.height;
   
   window.resizeTo(width,height);
}
</script>

<head></head>
<BODY bgcolor="0099CC" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="win_onLoad();">
<TABLE width="95%" border="0" cellpadding="0" cellspacing="0" class="table-left1-right2"  style="border:1 solid #000000" id="tblList">
<TR>
<TD width="100%" valign="top" colspan=2>
欢迎使用!
</TD>
</TR>
</TABLE>
</BODY>
</html>
我要 [保存此页] [收藏此页] [复制此链接QQ/Msn发送]
收藏到 [天天] [和讯] [我摘] [天极] [新浪] [博采] [Del.icio.us]
我们推荐您 快去试试吧!
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]