首页 > 其他 > 详细

取到easyui的tab下iframe方法

时间:2015-03-26 15:24:21      阅读:149      评论:0      收藏:0      [点我收藏+]

我们在使用easyui的tab时,有时候需要每次点击tab头,动态刷新该tab下的iframe的内容

tab的html如下:

Html代码:

<div id="tab-user-right" >   
        <div title="直接分配的操作权限" id="user-right-act">             
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="拥有的角色" id="user-role">              
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="继承自角色的权限" id="user-right-role">             
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="全部操作权限" id="user-right-all">            
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="数据权限-机构" id="user-right-org">           
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
        <div title="数据权限-部门" id="user-right-dept">              
            <iframe scrolling="yes" frameborder="0" height="500" width="100%"  frameborder="0" ></iframe>  
        </div>  
    </div>

动态刷新的js如下:

//标记是否从新刷新  
        var reload="T";  
        $(function(){  
            $(‘#tab-user-right‘).tabs({   
                onSelect: function(){  
                    openTab();                                        
                }  
            });  
        });  
          
        function openTab(){           
            var tab = $(‘#tab-user-right‘).tabs(‘getSelected‘);  
            var tbId = tab.attr("id");  
            //获取tab的iframe对象  
            var tbIframe = $("#"+tbId+" iframe:first-child");  
            if(reload=="T"){                  
                tbIframe.attr("src",tbId+‘.action?userId=‘+userId);  
            }else{        
                if( tbIframe.attr("src")==""){  
                  tbIframe.attr("src",tbId+‘.action?userId=‘+userId);  
                }  
            }  
        }

注意一下代码:

Js代码

  1. var tab = $(‘#tab-user-right‘).tabs(‘getSelected‘);  

  2.             var tbId = tab.attr("id");  

  3.             //获取tab的iframe对象  

  4.             var tbIframe = $("#"+tbId+" iframe:first-child"); 




取到easyui的tab下iframe方法

原文:http://my.oschina.net/u/2331760/blog/392044

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!