html 后台导航 iframe 点击换url

写了个小项目,上网随便找了个后台模板 ,又不想重复加载head,footer......

想到了用iframe ....  哈哈哈哈 随便写写.... 随意挑错 .... 欢迎大家指教

id=“nav_menu” 加在了二级菜单的 ul 上........

    <script type="text/javascript">
        //导航
        $('#nav_menu a').click(function(){
            //选中样式
            $(".am-fr").removeClass('am-icon-star');
            $(this).children('.am-fr').addClass('am-icon-star');
            //url
            href = $(this).attr('href');
            $('#iframe').attr('src',href);
            if_title = $(this).children('span').text();
            var iframe = document.getElementById("iframe");
            //iframe加载完,隐藏滚动条,替换内容里title
            iframe.onload = function(){
                hideS();
                document.title = iframe.contentWindow.document.title;
                $("#iframe").contents().find("#if_title").text(if_title);
            } 
            return false;
        });

        /*//iframe是否加载完,并且隐藏滚动条
        var iframe = document.getElementById("iframe");
        if (iframe.attachEvent){
          iframe.attachEvent("onload", function(){
            hideS();

          });
        } else {
          iframe.onload = function(){
            hideS();
            document.title = iframe.contentWindow.document.title;
          };
        }*/

        function hideS()
        {
          document.getElementById("iframe").scrolling="no";
          document.getElementById("iframe").style.overflow="hidden";
        }
    </script> 

 

 

<script type="text/javascript">
    //导航
    $('#nav_menu a').click(function(){
        //选中样式
        $(".am-fr").removeClass('am-icon-star');
        $(this).children('.am-fr').addClass('am-icon-star');
        //url
        href = $(this).attr('href');
        $('#iframe').attr('src',href);
        return false;
    });


    //iframe是否加载完,并且隐藏滚动条
    var iframe = document.getElementById("iframe");
    if (iframe.attachEvent){
      iframe.attachEvent("onload", function(){
        hideS();

      });
    } else {
      iframe.onload = function(){
        hideS();
        document.title = iframe.contentWindow.document.title;
      };
    }

    function hideS()
    {
      document.getElementById("iframe").scrolling="no";
      document.getElementById("iframe").style.overflow="hidden";
    }
</script> 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值