iframe表单提交后自动关闭
background: 因为项目需要,要用dialog插件实现新增功能页面
demands:
1.高度自适应:
autoFit :true
2.新增结束窗口关闭
方法1:
thinkphp:
$this->assign('jumpUrl','javascript:window.close();'); 跪了 刷新页面了
方法2:
js:
$("#form0").submit(function(){
window.close();
});
window.close();
});
跪了 还是没用
=> 跳转到另外一个页面 然后执行window.close() 有用 => 但是dialog插件留下的容器还在
方法3
设置了form 的target属性
依旧跪 主页面跳转到了新增的表单页面
2015/11/16-----解决
方法4
外层页面使用
<form class="ui-form mt20" name="form" method="post" action="{:U('Schedule/insert')}" id="myform" data-widget="validator">
<fieldset>
<input type ="hidden" name="scheduletype" id="scheduletype" />
<input type ="hidden" name="startdate" id="startdate" />
</form>
内层页面使用
function deleteIframe(){
window.parent.document.getElementById("creater").value = document.getElementsByName("creater")[0].value ;
window.parent.document.getElementById("foodcondition").value = $("input[name='foodcondition']:checked").val();
window.parent.document.getElementById("leaderuserid").value = $("#leaderuserid").val();
window.parent.document.getElementById("leadername").value = $("#leaderuserid").find("option:selected").text();
window.parent.document.getElementById("myform").submit();
}
js父子页面获取对象
1.在iframe子页面中获取父页面的元素:
window.parent.document这个是获取父页面document中的对象;
如果要获取父页面js中的方法:window.parent.xxxx();xxxx()为方法;
2.在父页面中获取iframe子页面中的元素: