111 js iframe表单提交后自动关闭 &

来源:互联网 发布:java反序列化漏洞原理 编辑:程序博客网 时间:2024/05/29 05:10

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()    有用  => 但是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子页面中获取父页面的元素:

    a>

          window.parent.document这个是获取父页面document中的对象;

    b>

          如果要获取父页面js中的方法:window.parent.xxxx();xxxx()为方法;

2.在父页面中获取iframe子页面中的元素:

   a>

     var child = document.getElementByIdx_x("mainFrame").contentWindow;//mainFrame这个id是父页面iframe的id

     child.document;//获取子页面中的document对象;




0 0
原创粉丝点击