A fairly simple prototype based tab view function which renders simple html lists into navigable tabbed views of content.
Create a Simple Tab View just like this one with four
simple steps:
![]()
How does Simple Tabview work?
It turns a simple html ul-list into a navigable tabview by
surrounding it with a
container-element and inserting tab-headers for each
<li>-entry:
![]()
How to implement "Simple Tabview"?
Step 1: Include all necessary files into your page
- prototype.js (get prototype)
- tabview.js
- tabview.css
- <script src="prototype.js" type="text/javascript">
- <script src="tabview.js" type="text/javascript">
- <link href="%3Cstrong%3Etabview.css%3C/strong%3E" rel="stylesheet" type="text/css"/>
Step 2: Create a html ul- or ol-list which shall be transformed into a tabview
- Create a <ul> list and apply the class
"tab-collection" to it:
<ul class="tab-collection">
...
</ul> - Add tabs to the tabview by adding simple list elements <li
title="tab headline">...</li>
with a title attribute which defines the headline for each tab:
<li title="Tab1 Headline"> Yada Yada Tab 1 </li>
<li title="Tab 2 Headline"> Lorem ipsum Tab 2 </li>
<li title="..."> ... </li>
<li title="Tab X Headline"> Some Content </li> - Example: Screenshots-Simple-JavaScript-TabView-HTML-Code-002.png

Step 3: Initialize the tabview Add this JavaScript block at the bottom of your website.
The JavaScript method UI.Tabview.init(root, options) will render each tab collection which is a child element of root into a tabview. Example function call: UI.Tabview.init()
UI.Tabview.init(
'containerid',
{
width: '500px',
activeColorBackground: 'black',
activeColorText: 'white',
inactiveColorBackground: 'white',
inactiveColorText: 'black'
}
);
Note: The options are not mandatory - If they are not set, the function will use default values.
Step 4: View the result
A UL-list like this will look something like the screenshot below
(try the demo: tabview-demo.html):
<ul class="tab-collection">
<li class="tab" title="Tab1">
<h3>Tab 1</h3>
<img src="image1.jpg" border="0" />
</li>
<li class="tab" title="Tab2">
<h3>Tab 2</h3>
<img src="image2.jpg" border="0" />
</li>
<li class="tab" title="Tab3">
<h3>Tab 3</h3>
<img src="image3.jpg" border="0" />
</li>
</ul>
Screenshot of a Tabview: Screenshots-Simple-JavaScript-TabView-001.png
![]()
Customize the Look & Feel
Feel free to modify the look of your tabview by changing some of
the colors, the padding or text style or even the
JavaScript-Function. There is no magic behind and the layout should
stay intact as long as you don't mess with the the
float, position,
width or margin-attributes.
Limitations
If you have too many tabs it will look crappy.
Compatibility
The tabview.js script works with
- Firefox
- Internet Explorer 6
- Internet Explorer 7
- Internet Explorer 8
- Google Chrome
- Opera
- Safari
- Flock
- ...
| Browser | Versions |
|---|---|
| Firefox |
|
| Internet Explorer |
|
| Google Chrome |
|
| Opera |
|
| Safari |
|
| Flock |
|
| Epiphany |
|
| Galeon |
|
| Konqueror |
|
| Seamonkey |
|
But see for yourself at browsershots.org
Mahalo!
- Andreas
Attachments
Simple-JavaScript-TabView.tar
Download the TabView Demo - a simple JavaScript function which creates a navigable tab view of html markup
Simple-JavaScript-TabView.zip
Download the TabView Demo - a simple JavaScript function which creates a navigable tab view of html markup
Screenshots-Simple-JavaScript-TabView-001.png
Screenshot of TabView created from html markup code
prototype.js
Prototype Framework (Version: 1.6.0.2)
tabview.css
tabview.css is needed for tabview.js to render a simple html list into a navigable tabview
tabview.js
tabview.js contains a javascript function converts a html list into a navigable tabview
tabview-demo.html
this html page uses tabview.js to render a simple html ul-list into a navigable tabview
Screenshots-Simple-JavaScript-TabView-HTML-Code-002.png
TabView HTML Code
Tabview-DOM-Layout.jpg
Tabview DOM-Layout schema (JPEG) illustrates how the tabview script turns a simple -list into a navigable tabview
Browser-Compatibility-Test-Simple-TabView-Screenshots-(prototype.js).zip
A bunch of Screenshot of Simple Tab View in different Browsers (Firefox, Internet Explorer, Opera, Safari, ...) on different operating systems (Windows XP, Gentoo, Ubuntu, Free BSD, Mac OS X, ...)
sitemap.xml Simple-JavaScript-tab-view.kml Simple-JavaScript-tab-view.rss Simple-JavaScript-tab-view.xml Simple-JavaScript-tab-view.json Simple-JavaScript-tab-view.print
http://andykdocs.de/andykdocs/document/A-simple-jQuery-Script-for-creating-SEO-friendly-and-accessible-TabView-controls
In the jQuery version of the TabView is the process of creating the control still the same as described in this document, but the JavaScript code is a little bit cleaner and more robust.
Greetings
– Andreas aka AndyK