Content in the Javascript library assumes a sound understanding of ECMAScript, CSS, XHTML and DOM.

Tabbed Panels

Code listing for tp.html

Including the javascript code

  1. <script type="text/javascript" src="/js/tp/tp.js"></script>
  2. <link rel="stylesheet" href="/js/tp/tp.css" />

Starting the script

  1. <body onload="tpSet('control', 'tabs', 'tp1', 'tp2', 'tp3');">

Writing the content of each panel

Write your content the way you want it to be seen if the tabbed panel javascript doesn’t work.

  1. <div id="control">
  2. <!-- any content in here (except panels) will be replaced with the tabs -->
  3. <div id="tp2" title="Tab 2">
  4. <!-- your content for the second tab goes in here -->
  5. </div>
  6. <div id="tp1" title="Tab 1">
  7. <!-- your content for the first tab goes in here -->
  8. </div>
  9. </div>
  10. <div id="tp3" title="Tab 3">
  11. <!-- your content for the third tab goes in here -->
  12. </div>

Preview

Note: Comments have been replaced with <p> for this preview. Also, tp1 and tp2 have been swapped. In the source code, tp2 comes first. By specifying tp1 first in the call to tpSet, it becomes the first tab, ahead of tp2.

any content in here (except panels) will be replaced with the tabs

your content for the second tab goes in here

your content for the first tab goes in here

your content for the third tab goes in here

[ inspire logo ]
Code in the javascript library is free to use. Enjoy! Feedback welcome.
© Ben Boyle 2003.