弹出窗口根据内容自动调整大小的JS解决方案
2007-09-21 10:11
871 查看
父类(主/打开)窗口中代码为:
<html>
<head><title>父类窗口</title>
<script type="text/javascript">...
var s,oRes;
function openwin(url)
...{
s=window.open("child.htm");
oRes=s.document.getElementById("txt");
//文本改变时还回
//oRes.onchange=function(){
//alert("text changed");
//document.getElementById("txtRet").value=oRes.value;}
//子窗口关闭时还回,另一种方法传参数
//var btnChild=s.document.getElementById("btnSubmit");
//btnChild.onclick=function(){
//alert("btn clicked");
//document.getElementById("txtRet").value=oRes.value;}
}
function childclose(txt)
...{
document.getElementById("txtRet").value=txt;
}
</script>
<body>
<form>
<input type="text" id="txtRet" name="txtRet" />
<input type="button" value="按钮" onclick="openwin('child.htm')" />
</form>
</body>
</html>
在之类弹出窗口加入resizeto(window.clientWidth,window,clientHeight)代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>子类窗口</title>
<script type="text/javascript">...
window.open=function() ...{
if(window.opener)
...{
width=document.body.clientWidth+33;
height=document.body.clientHeight+50;
window.resizeTo(width,height);
}
}
</script>
</head>
<body style="margin:0px;" onload="win_onLoad()">
<input type="text" id="txt" name="txt" />
<input type="button" id="btnSubmit" name="btnSubmit" value="确定" />
<script type="text/javascript">...
btnSubmit.onclick=function()...{
if(window.opener)
...{
window.opener.childclose(document.getElementById("txt").value);
window.setTimeout(function()...{self.close();},500);
}
else
...{
self.close();
}
}
</script>
</body>
</html>
referrence:http://topic.csdn.net/t/20040623/09/3114967.html
<html>
<head><title>父类窗口</title>
<script type="text/javascript">...
var s,oRes;
function openwin(url)
...{
s=window.open("child.htm");
oRes=s.document.getElementById("txt");
//文本改变时还回
//oRes.onchange=function(){
//alert("text changed");
//document.getElementById("txtRet").value=oRes.value;}
//子窗口关闭时还回,另一种方法传参数
//var btnChild=s.document.getElementById("btnSubmit");
//btnChild.onclick=function(){
//alert("btn clicked");
//document.getElementById("txtRet").value=oRes.value;}
}
function childclose(txt)
...{
document.getElementById("txtRet").value=txt;
}
</script>
<body>
<form>
<input type="text" id="txtRet" name="txtRet" />
<input type="button" value="按钮" onclick="openwin('child.htm')" />
</form>
</body>
</html>
在之类弹出窗口加入resizeto(window.clientWidth,window,clientHeight)代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>子类窗口</title>
<script type="text/javascript">...
window.open=function() ...{
if(window.opener)
...{
width=document.body.clientWidth+33;
height=document.body.clientHeight+50;
window.resizeTo(width,height);
}
}
</script>
</head>
<body style="margin:0px;" onload="win_onLoad()">
<input type="text" id="txt" name="txt" />
<input type="button" id="btnSubmit" name="btnSubmit" value="确定" />
<script type="text/javascript">...
btnSubmit.onclick=function()...{
if(window.opener)
...{
window.opener.childclose(document.getElementById("txt").value);
window.setTimeout(function()...{self.close();},500);
}
else
...{
self.close();
}
}
</script>
</body>
</html>
referrence:http://topic.csdn.net/t/20040623/09/3114967.html
相关文章推荐
- 根据内容自动调整弹出窗口大小的JS解决方案
- 根据内容自动调整弹出窗口大小的JS解决方案
- 根据内容自动调整弹出窗口大小的JS解决方案
- 根据内容自动调整弹出窗口大小的JS解决方案
- 根据内容自动调整弹出窗口大小的JS解决方案 选择自 WeekZero 的 Blog
- 根据内容自动调整弹出窗口大小的JS解决方案
- 根据内容自动调整弹出窗口大小的JS解决方案
- 根据内容自动调整弹出窗口大小的JS解决方案
- 弹出窗口根据内容调整大小并居中的JS实现(适用IE、活动窗口和模式窗口)
- window.onload and showModalDialog根据内容自动调整窗口大小
- showModalDialog根据内容自动调整窗口大小
- showModalDialog根据内容自动调整窗口大小
- java 添加背景图片(可根据窗口大小自动调整显示图片)
- QTableView根据内容自动调整大小(resizeColumnToContents解决不了的)
- 窗口根据屏幕分辨率自动调整大小
- AutoFitTextView-根据文本内容自动调整字体大小的TextView
- [JS]iframe根据子页面自动调整大小
- 把界面上静态文本控件的尺寸根据文本的内容自动调整大小(转)
- 把界面上静态文本控件的尺寸根据文本的内容自动调整大小(转)
- iframe自动根据内容调整大小