Below is the code I have for a header:
<div id="title-text">
The Cuttlefisher Paradise
</div>
<div id="choices">
<ul>
<li id="home"><a href="#">Home</a></li>
<li id="contact"><a href="#">Contact</a></li>
<li id="about"><a href="#">About</a></li>
<!-- 5 more items -->
</ul>
</div>
I need to use this as the header on around 10 different web pages, but without using <frame>
or <iframe>
. It's important for graphical reasons.
Currently, I am using
document.getElementById("home").setAttribute("class", "active")
to style the active tab. However, when the header (the block of code above) is inserted into a div using innerHTML
, document.getElementById
doesn't work and returns null.
Is there a simple method to include the header on multiple pages without <frame>
or <iframe>
, or to make document.getElementById
identify ids inserted with innerHTML
?