Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

need an HTML table of contents which can be turned on or off by the user

Posted on 2007-07-30
3
Medium Priority
?
164 Views
Last Modified: 2010-04-09
I'd like a table of contents and considered using an entire pane on one side, but it took up to much room.

Any suggestions about how to keep the functionality of a table of contents but have it be an option to the user?

thanks,
newbieweb
0
Comment
Question by:newbieweb
  • 3
3 Comments
 
LVL 9

Expert Comment

by:sundaramkumar
ID: 19597913
add a style to the table of contents div/ table

as <div id="toc" style="display:none">
....
....
...

</div>

Now add a button/small image for table of contents
<img src="yourimage" onclick="showToc()">

add javascript fn

function showToc()
{
 if(document.getElementById('toc').style.display=='none')
  document.getElementById('toc').style.display='block';
 else
  document.getElementById('toc').style.display='none'
}
0
 
LVL 9

Expert Comment

by:sundaramkumar
ID: 19597916
So whenever the image is clicked the toc will shown if it is hidden. if the image is clicked again the toc will hide.

0
 
LVL 9

Accepted Solution

by:
sundaramkumar earned 2000 total points
ID: 19606402
a working sample is below
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>welcome</TITLE>
<script language="javascript">
function Toggle(){
   var tocStyle = document.getElementById('toc').style;
   if(tocStyle.display=='none')tocStyle.display='block';
   else if(tocStyle.display='block')tocStyle.display='none';
}

</script></HEAD>

<BODY>
<div style="float:right"><a href="#" onclick="javascript: Toggle()">Table of Contents</a></div>
<br/><br/>
<p>
blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
</p>
<br/><br/>
<p>
blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
</p>
<br/><br/>
<p>
blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
</p>
<br/><br/>
<p>
blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah
</p>
<div id="toc" style="position:absolute;width:150px;height:100px;top:50px;left:1px;display:none;Z-index:10;background-color:#FFFFFF;-moz-opacity:0.90;filter:alpha(opacity=90,finishopacity=90);border:1px #a1bcdf solid">
<li>1.Index</li>
<li>2.Intro</li>
<li>3.How to</li>
<li>4.Conclusion</li>
<li>5.Bibliography</li>
</div>
</BODY>
</HTML>
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question