<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html dir="ltr" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
	<title>DOMTab - Navigation tabs with CSS and DOMscripting</title>
	<style type="text/css">
		@import "domtab.css";
	</style>
<!--[if gt IE 6]>
	<style type="text/css">
		html>body ul.domtabs a:link,
		html>body ul.domtabs a:visited,
		html>body ul.domtabs a:active,
		html>body ul.domtabs a:hover{
			height:3em;
		}
	</style>
<![endif]-->
	<script type="text/javascript" src="domtab.js"></script>
	<script type="text/javascript">
		document.write('<style type="text/css">');    
		document.write('div.domtab div{display:none;}<');
		document.write('/s'+'tyle>');    
    </script>
</head>
<body>

<h1><a name="top" id="top">DOMTab - Navigation tabs with CSS and DOMscripting</a></h1>
<p id="domtabprintview"></p>
<div class="domtab">
	<ul class="domtabs">
		<li><a href="#what">What is DOMtab?</a></li>
		<li><a href="#how">How to use DOMtab</a></li>
		<li><a href="#pr">Previous and next links</a></li>
		<li><a href="#style">How to style DOMtab</a></li>
		<li><a href="#dl">Download</a></li>
	</ul>
	<div>
		<h2><a name="what" id="what">What is DOMtab?</a></h2>
		<p>DOMtab is a JavaScript that turns a list of links connected to content
		sections into a tab interface. The script removes any "back to top" links 
		in the section and automatically hides all but the first one when the 
		page is loaded. You can use as many tabbed menus on the page as you want 
		to.</p>
		<p><strong>New:</strong> If the URL of the page links directly to one of the tabs it get automatically 
		highlighted.</p>
		<p>You can define with an extra class if you want previous and next links 
		or not.</p>
		<p>DOMtab uses Unobtrusive JavaScript and does not have any global functions or variables. This page uses DOMtab.</p>		
		<p><strong>To do:</strong> internal links highlighting tabs (too busy for that now)</p>
		<p><a href="http://www.wait-till-i.com/index.php?p=242">Comment on the Blog</a></p>
		<p><a href="https://www.paypal.com/xclick/business=donations%40onlinetools.org&#38;return=http%3A//www.onlinetools.org/ohcheers.php&#38;cancel_return=http%3A//onlinetools.org/">Donations help me buy coffee to stay awake!</a></p>
		<p><a href="#top">back to menu</a></p>
	</div>
	<div>
		<h2><a name="how" id="how">How to use DOMtab</a></h2>
		<p>Applying DOMtab to your pages is easy, all you need is to call the 
		script in the head of the document:</p>
<pre><code>&#60;script type=&#34;text/javascript&#34; src=&#34;domtab.js&#34;&#62;&#60;/script&#62;</code></pre>
		<p>DOMtab expects the following classes and element structure to work:</p>
<pre><code>&#60;div class=&#34;<strong>domtab</strong>&#34;&#62;
  &#60;ul class=&#34;<strong>domtabs</strong>&#34;&#62;
    &#60;li&#62;&#60;a href=&#34;#<strong>t1</strong>&#34;&#62;Test 1&#60;/a&#62;&#60;/li&#62;
    &#60;li&#62;&#60;a href=&#34;#t2&#34;&#62;Test 2&#60;/a&#62;&#60;/li&#62;
[... and so on ...]
  &#60;/ul&#62;
  &#60;div&#62;
    &#60;h2&#62;&#60;a name=&#34;t1&#34; id=&#34;<strong>t1</strong>&#34;&#62;Proof 1&#60;/a&#62;&#60;/h2&#62;
    &#60;p&#62;Test to prove that more than one menu is possible&#60;/p&#62;
    &#60;p&#62;&#60;a href=&#34;#top&#34;&#62;back to menu&#60;/a&#62;&#60;/p&#62;
  &#60;/div&#62;
  &#60;div&#62;
    &#60;h2&#62;&#60;a name=&#34;t2&#34; id=&#34;t2&#34;&#62;Proof 2&#60;/a&#62;&#60;/h2&#62;
    &#60;p&#62;Test to prove that more than one menu is possible&#60;/p&#62;
    &#60;p&#62;&#60;a href=&#34;#top&#34;&#62;back to menu&#60;/a&#62;&#60;/p&#62;
  &#60;/div&#62;
[... and so on ...]
&#60;/div&#62;</code></pre>
<p>The showing and hiding of sections is achieved by reading out the hash data 
of the link url and retrieving the parent element of the element with the ID the 
original link points to.</p>
<p>The links to remove are identified via a pattern in their href attribute, preset to "#top".</p>
<p>If there is an element with the id <strong>domtabprintview</strong> in the document, DOMtab will
create a link to show all elements in this one.</p>
<p>You can change all the settings in the script itself, as all HTML expections are 
parameters:</p>
<pre><code>tabClass:'domtab', // class to trigger tabbing
listClass:'domtabs', // class of the menus
activeClass:'active', // class of current link
contentElements:'div', // elements to loop through
backToLinks:/#top/, // pattern to check "back to top" links
printID:'domtabprintview', // id of the print all link
showAllLinkText:'show all content', // text for the print all link
</code></pre>
		<p><a href="#top">back to menu</a></p>
	</div>
	<div>
		<h2><a name="pr" id="pr">Previous and next links</a></h2>
		<p>In this version I added the option to have previous and next links 
		to navigate around the tabs in addition to clicking them.</p>
		<p>If you want DOMtab to generate those, all you need to do is to 
		add the class &#34;doprevnext&#34; in addition to the domtab class to 
		the div in question:</p>
<pre><code>&#60;div class=&#34;domtab <strong>doprevnext</strong>&#34;&#62;
  &#60;ul class=&#34;domtabs&#34;&#62;
    &#60;li&#62;&#60;a href=&#34;#t1&#34;&#62;Test 1&#60;/a&#62;&#60;/li&#62;
    &#60;li&#62;&#60;a href=&#34;#t2&#34;&#62;Test 2&#60;/a&#62;&#60;/li&#62;
    &#60;li&#62;&#60;a href=&#34;#t3&#34;&#62;Test 3&#60;/a&#62;&#60;/li&#62;
    &#60;li&#62;&#60;a href=&#34;#t4&#34;&#62;Test 4&#60;/a&#62;&#60;/li&#62;
  &#60;/ul&#62;
  [... ad nauseam...]
&#60;/div&#62;</code></pre>
<p>DOMtab then generates the following link list in each of the sections, automatically 
removing the previous link in the first and the next in the last section:</p>
<pre><code>&#60;ul class=&#34;prevnext&#34;&#62;
  &#60;li class=&#34;prev&#34;&#62;&#60;a href=&#34;#&#34;&#62;previous&#60;/a&#62;&#60;/li&#62;
  &#60;li class=&#34;next&#34;&#62;&#60;a href=&#34;#&#34;&#62;next&#60;/a&#62;&#60;/li&#62;
 &#60;/ul&#62;</code></pre>
<p>Once again, you can override any of these settings in the script's parameters:</p>
<pre><code>prevNextIndicator:'doprevnext', // class to trigger links
prevNextClass:'prevnext', // class of the prev and next list
prevLabel:'previous', // HTML content of the prev link
nextLabel:'next', // HTML content of the next link
prevClass:'prev', // class for the prev link
nextClass:'next', // class for the next link
</code></pre>
<p>Both labels are set via innerHTML rather than the proper method :-). This allows you to
use images if wanted:</p>
<pre><code>prevLabel:'&#60;img src=&#34;massivebuttonprev.png&#34; alt=&#34;previous&#34; /&#62;',</code></pre>
		<p><a href="#top">back to menu</a></p>
	</div>
	<div>
		<h2><a name="style" id="style">How to style DOMtab</a></h2>
		<p>Using the mandatory classes domtab for the main DIV of each menu, 
		and domtabs for the menu list, you can pretty much style your menus 
		any way you want to.</p>
		<p>DOMtab adds the class "active" to the LI containing the currently 
		active link, to allow you to highlight the currently chosen tab.</p>
		<p>The previous and next links get classes on their own, which makes 
		it easy to style them differently.</p>
		<p>The showing and hiding of the sections is done via JavaScript using 
		display block and none. It would be pretty easy to replace this with 
		a styleable show and hide class, if you want to have that, please 
		contact me on the blog.</p>
		<p>If you want to avoid the initial flash of all the content until the 
		script kicks in, you can cheat by adding the following code in the head
		right after the script element with the domtab call:</p>
<pre><code>
&#60;script type=&#34;text/javascript&#34;&#62;
  document.write('&#60;style type=&#34;text/css&#34;&#62;');    
  document.write('div.domtab div{display:none;}&#60;');
  document.write('/s'+'tyle&#62;');    
&#60;/script&#62;
</code></pre>
		<p><a href="#top">back to menu</a></p>
	</div>
	<div>
		<h2><a name="dl" id="dl">Download DOMtab</a></h2>
<p>DOMtab is provided as-is and I don't take any responsibility for any problems 
that might occur for using it.</p>
<p>It is free to use, but not free to resell. If you want to use DOMtab in a 
commercial site/product please contact me.</p>
<ul>
	<li><a href="domtab.zip">DOMtab version 3.1415927</a>
</ul>

		<p><a href="#top">back to menu</a></p>
	</div>
</div>
<div id="other" class="domtab doprevnext">
	<ul class="domtabs">
		<li><a href="#t1">Test 1</a></li>
		<li><a href="#t2">Test 2</a></li>
		<li><a href="#t3">Test 3</a></li>
		<li><a href="#t4">Test 4</a></li>
	</ul>
	<h2>You can use content in between the tabs and the sections</h2>
	<div>
		<h2><a name="t1" id="t1">Proof 1</a></h2>
		<p>Test to prove that more than one menu is possible</p>
		<p><a href="#top">back to menu</a></p>
	</div>
	<div>
		<h2><a name="t2" id="t2">Proof 2</a></h2>
		<p>Test to prove that more than one menu is possible</p>
		<p><a href="#top">back to menu</a></p>
	</div>
	<div>
		<h2><a name="t3" id="t3">Proof 3</a></h2>
		<p>Test to prove that more than one menu is possible</p>
		<p><a href="#top">back to menu</a></p>
	</div>
	<div>
		<h2><a name="t4" id="t4">Proof 4</a></h2>
		<p>Test to prove that more than one menu is possible</p>
		<p><a href="#top">back to menu</a></p>
	</div>
</div>

</body>
</html>
