Layer obtain js method of dom iframe elements and call the iframe page

1. the parent page click the first button trigger, get the body element sub-page, call the js method defined in sub-pages

Yes: function (index, layero) {
     // Get iframe body element 
    var body = layer.getChildFrame ( 'body' , index);
     // get page iframe window object 
    var iframeWin = window [layero.find ( 'iframe' ) [0] [ 'name' ]]; 
     // showMsg method performed iframe page 
    iframeWin.showMsg ( "Mercy" ); 
                    
    the console.log (iframeWin); 
    the console.log ( "Yes callback:" + body.html ()); 
    the console.log (layero, index); 
}

2. subpages defined showMsg () method:

<script type="text/javascript">
 
    function showMsg(msg){
        layer.msg(msg);
    }
</script>

Guess you like

Origin www.cnblogs.com/lxl57610/p/10971952.html