弹出窗口根据内容自动调整大小的JS解决方案
来源:互联网 发布:2016淘宝双十一记录 编辑:程序博客网 时间:2024/04/30 15:22
父类(主/打开)窗口中代码为:
<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>
<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>
<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解决方案
- 根据内容自动调整弹出窗口大小的JS解决方案
- 弹出窗口根据内容自动调整大小的JS解决方案
- 根据内容自动调整弹出窗口大小的JS解决方案 选择自 WeekZero 的 Blog
- 弹出窗口根据内容调整大小并居中的JS实现(适用IE、活动窗口和模式窗口)
- showModalDialog根据内容自动调整窗口大小
- showModalDialog根据内容自动调整窗口大小
- window.onload and showModalDialog根据内容自动调整窗口大小
- 根据窗口大小自动调整元素大小
- Excel根据批注的内容自动调整批注大小
- 窗口根据屏幕分辨率自动调整大小
- 窗口根据屏幕分辨率自动调整大小
- 使IFrame根据内容自动调整大小
- iframe自动根据内容调整大小
- javascript 右键菜单
- C++/CLI中的资源清理(Destructor,Finalizer)
- Ajax 页面无刷新技术学习(GET)
- Oracle DBA最常碰到的10个Oracle错误
- 在IE中显示pdf文档的方法及参数设置
- 弹出窗口根据内容自动调整大小的JS解决方案
- UNIX操作系统优势总结
- .NET设计模式开篇
- [转]session_onend 的充要条件
- .NET设计模式(2):单件模式(Singleton Pattern)
- 最新破解QQ空间收费物品的真实地址(完全可免费使用)
- .NET设计模式(3):抽象工厂模式(Abstract Factory)
- js----禁止文本粘贴功能
- Submitting Xml Documents to BizTalk 2006 via SOAP