layer的iframe層的傳參和回參


從父窗口傳參給iframe,參考://https://yq.aliyun.com/ziliao/133150

從iframe回參給父窗口,參考:https://www.cnblogs.com/jiqing9006/p/5135697.html

 

父窗口隱藏ID

<input type='text' id="handle_status" value="" hidden="hidden">

 

父窗口核心兩個方法是success,end

                layer.open({
                    type:2,
                    content: '/role/edit?id='+id,
                    area:['500px', '500px'],
                    success:function(layero, index){
                        //向iframe頁的id=age的元素傳值 
                        var body = layer.getChildFrame('body', index);
                        body.contents().find("#age").val(111);
                    },
                    end:function(){
              //父窗口有一個隱藏id=handle_status的元素,從這里取iframe返回值 var hstatus = $('#handle_status').val(); alert(hstatus); } });

iframe窗口寫值給父窗口id=handle_status

            var index = parent.layer.getFrameIndex(window.name); //取得iframe窗口index值
                parent.$("#handle_status").val(555); //向父窗口寫值
                parent.layer.close(index); //根據index值,關閉iframe窗口

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM