[Jquery Ui]Tabs與iframe

來源:互聯網
上載者:User

標籤:

關鍵代碼:

(function (window) {    yjqueryuiUtils = {        tab: {            addIframe: function (tabid) {                /// <summary>                /// tabs嵌套iframe                /// <para>樣本:yjqueryuiUtils.tab.addIframe(‘tabs‘); </para>                /// <para>參考:http://deano.me/2011/08/jquery-tabs-iframes/ </para>                /// <para>說明:每個Tabpage應設定href,id,rel屬性</para>                /// </summary>                /// <param name="tabid">tabs的ID</param>                var tabs = $(‘#‘ + tabid).tabs();                var url = $("#tabs ul li:eq(" + 0 + ")").find("a");                this.addEveryIframe(url.attr("href"), url.attr("rel"), url.attr("id"));                $("#" + tabid + " ul li a").click(function () {                    yjqueryuiUtils.tab.addEveryIframe($(this).attr("href"), $(this).attr("rel"), $(this).attr("id"));                });            },            addEveryIframe: function (href, rel, id) {                /// <summary>                /// tabs嵌套iframe                /// </summary>                /// <param name="href">超連結的href</param>                /// <param name="rel">超連結的rel</param>                /// <param name="id">超連結的id</param>                if ($(href).find("iframe").length == 0) {                    var openout = $("#tp" + id), iframetab = $("#tpiframe" + id);                    if (openout.length == 0 && iframetab.length == 0) {                        var html = [];                        html.push(‘<div>‘);                        html.push(‘<div id="tp‘ + id + ‘"></div><iframe id="tpiframe‘ + id + ‘" src="‘ + rel + ‘"/>‘);                        html.push(‘</div>‘);                        $(href).append(html.join(""));                        openout = $("#tp" + id), iframetab = $("#tpiframe" + id);                        openout.css({                            ‘float‘: ‘right‘,                            ‘position‘: ‘relative‘,                            ‘top‘: ‘-28‘,                            ‘left‘: ‘-5‘                        });                        iframetab.css({                            ‘width‘: ‘100%‘,                            ‘height‘: ‘auto‘,                            ‘border‘: ‘0‘,                            ‘margin‘: ‘0‘,                            ‘position‘: ‘relative‘,                            ‘top‘: ‘0‘,                            ‘background‘: ‘white‘                        });                    }                    $(href).find("iframe").height($(window).height() - 80);                }                return false;            }        }    }    window.yjqueryuiUtils = yjqueryuiUtils;})(window);

樣本:

<html><head>    <script src="jquery-ui-1.11.2.custom/external/jquery/jquery.js"></script>    <script src="jquery-ui-1.11.2.custom/jquery-ui.js"></script>    <link href="jquery-ui-1.11.2.custom/jquery-ui.css" rel="stylesheet" />    <script src="yjqueryuiUtils.js" type="text/javascript"></script>    <style>        html {            font-size: 10px;        }    </style>    <script>        $(document).ready(function () {            yjqueryuiUtils.tab.addIframe(‘tabs‘);        });    </script></head><body>    <div id="tabs">        <ul>            <li><a href="#tabs-1" id="tab1" rel="http://www.baidu.com">baidu</a></li>            <li><a href="#tabs-2" id="tab2" rel="http://www.microsoft.com">microsoft</a></li>            <li><a href="#tabs-3" id="tab3" rel="http://www.bing.com">bing</a></li>        </ul>        <div id="tabs-1">        </div>        <div id="tabs-2">        </div>        <div id="tabs-3">        </div>    </div></body></html>

效果:

[Jquery Ui]Tabs與iframe

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.