基本标签(Basic Tabs)

现在PC已经越来越快,内存也越来越多,标签(tabs)已经在网络上广泛使用。

标签(tabs)可以很方便地在多个页面切换。

演示(demo)地址在文章最后.

效果图如下:

现在PC已经越来越快,内存也越来越多,标签(tabs)已经在网络上广泛使用。

标签(tabs)可以很方便地在多个页面切换。

演示(demo)地址在文章最后.

效果图如下:

用到的有三个文件tabs.html,tabs-example.js和tabs-example.css。

tabs.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Tabs Example</title>
    <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
    
    <!-- GC -->
 	<!-- LIBS -->
 	<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
 	<!-- ENDLIBS -->


    <script type="text/javascript" src="../../ext-all.js"></script>

    <!-- Tabs Example Files -->
    <link rel="stylesheet" type="text/css" href="tabs-example.css" />
    <script type="text/javascript" src="tabs-example.js"></script>

    <!-- Common Styles for the examples -->
    <link rel="stylesheet" type="text/css" href="../examples.css" />
</head>
<body>
<script type="text/javascript" src="../examples.js"></script><!-- EXAMPLES -->

<h1>Tab Panel Examples</h1>
<p>Note that the js and css is not minified so it is readable. See <a href="tabs-example.js">tabs-example.js</a> for the tab creation code
and <a href="tabs-example.css">tabs-example.css</a> for the css.</p>

    <h3>Tabs with auto height that resize to the content. Built from existing markup.</h3><br>

    <!-- container for the existing markup tabs -->
    <div id="tabs1">
        <div id="script" class="x-hide-display">
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus.<br/><br/> Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.</p>
        </div>
        <div id="markup" class="x-hide-display">
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.<br/><br/>Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit.</p>
        </div>
    </div>

    <br>
    <h3>Tabs with no tab strip and a fixed height that scroll the content. Built entirely with javascript.</h3>
    <ul class="list">
    <li>Tab 1 is a normal tab with content passed when adding it.</li>
    <li>Tab 2 is loaded via Ajax.</li>
    <li>Tab 3 is loaded via Ajax too. It was set up to pass parameters when loaded.</li>
    <li>Tab 4 has an event listener attached.</li>
    <li>Tab 5 is disabled.</li>
    </ul><br>


</body>
</html>

tabs-examples.js


Ext.onReady(function(){
    // basic tabs 1, built from existing content
    var tabs = new Ext.TabPanel({
        renderTo: 'tabs1',
        width:450,
        activeTab: 0,
        frame:true,
        defaults:{autoHeight: true},
        items:[
            {contentEl:'script', title: 'Short Text'},
            {contentEl:'markup', title: 'Long Text'}
        ]
    });

    // second tabs built from JS
    var tabs2 = new Ext.TabPanel({
        renderTo: document.body,
        activeTab: 0,
        width:600,
        height:250,
        plain:true,
        defaults:{autoScroll: true},
        items:[{
                title: 'Normal Tab',
                html: "My content was added during construction."
            },{
                title: 'Ajax Tab 1',
                autoLoad:'ajax1.htm'
            },{
                title: 'Ajax Tab 2',
                autoLoad: {url: 'ajax2.htm', params: 'foo=bar&wtf=1'}
            },{
                title: 'Event Tab',
                listeners: {activate: handleActivate},
                html: "I am tab 4's content. I also have an event listener attached."
            },{
                title: 'Disabled Tab',
                disabled:true,
                html: "Can't see me cause I'm disabled"
            }
        ]
    });

    function handleActivate(tab){
        alert(tab.title + ' was activated.');
    }
});

tabs-examples.css


.list {list-style:square;width:500px;padding-left:16px;}
.list li{padding:2px;font-size:8pt;}

pre {
   font-size:11px; 
}

.x-tab-panel-body .x-panel-body {
    padding:10px;
}

/* default loading indicator for ajax calls */
.loading-indicator {
	font-size:8pt;
	background-image:url('../../resources/images/default/grid/loading.gif');
	background-repeat: no-repeat;
	background-position: left;
	padding-left:20px;
}

.new-tab {
    background-image:url(../feed-viewer/images/new_tab.gif) !important;
}


.tabs {
    background-image:url( ../desktop/images/tabs.gif ) !important;
}

演示地址:http://extjs.org.cn/extjs/examples/tabs/tabs.html