首页 > 编程语言 > 详细

模式窗体中调用父页面Javascript

时间:2014-07-16 20:23:47      阅读:344      评论:0      收藏:0      [点我收藏+]

最近项目中使用模式窗体,遇到以下问题记录一下:

模式窗体:你必须关闭该窗体,才能操作其它窗体;比如说,必须按确定或取消,或者按关闭。

非模式窗体:不必关闭该窗体,就可转换到其它窗体上进行操作。

window.showModalDialog("a.html");//模式窗体

弹出的子页面,无法调用父页面里的js,从而刷新父页面,google一下,发现了解决方案:

  1. parent.html
<html>
<head>
<script language="text/javascript">
function openwindow(){
    retval=window.showModalDialog("child.html")
    Alert(retval);
    document.getElementById(text1).value=retval
}

function Alert(msg){
    alert(msg);
}
</script>
</head>
<body>
<form name=frm>
<input name=text1 type=text id="text1"/>
<input type=button onclick="javascript:openwindow()" value="Open window..">
</form>
</body>
</html>

2. child.html

<html>
<head>
<script language="javascript">
function changeparent(){
    window.returnValue="Value changed.."
    window.close()
}
</script>
</head>
<body>
<form>
<input type=button onclick="javascript:changeparent()" value="Change main window’s textbox value..">
</form>
</body>
</html>

 

模式窗体中调用父页面Javascript,布布扣,bubuko.com

模式窗体中调用父页面Javascript

原文:http://www.cnblogs.com/wspaceworld/p/3836821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!