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

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对象;




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值