I'm trying to figure out the best way to do this. I'm forced in a situation where php, mysql, etc are not available to me for this website. I'm stuck with pure client-side coding (HTML, CSS, JavaScript...)
I would like the ability that the PHP Includes statement gives me when it comes to maintaining navigation or other common page elements across a site. I know how to use CSS to handle the design of elements across a site. What I'm looking for is how to handle the other common elements without having PHP available to me.
I use a javascript menu file that I place on a page where I want the menu to show. Then I only have to update one file instead of 20 if I change anything on the menu.
Place this in your html where you want the menu to show:
I'm not a huge fan of frames either normally... that's why I was hoping to find a solution that didn't involve them.
The javascript looks like what I need. I'll give it a shot. It's a massive site that's going to continually be added to and updated... normally I'd be right on top of using a CMS solution like Wordpress or Joomla, but without php those just don't work.
Can you use javascript to pull in a whole element... like a <div> for the header or footer... essentially structuring the site like you would with php includes...
From what you're showing here, it looks like it...
Do not use the JavaScript method...it will fail for way too many users. Frames are yucky, but at least they work.
I would use XHTML but with the .XML file extension and text/xml MIME type. And I would use an XSLT stylesheet to add the navigation. But if I really wanted to make sure that every one and every robot could navigate the site then I would include in the XHTML a link to a page in HTML that is just the navigation and have the stylesheet remove that link.
“The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
—Tim Berners-Lee, W3C Director and inventor of the World Wide Web
The <object> tag seem to work fairly well to allow me to include an html file... the only issue I'm seeing right now is that when using it to pull in navigation, clicking on a link in the object opens the link in the object, not in the main page... ??
Ok... making pretty good progress at this point I think with the object tag, but having one issue at the moment... probably best to have this one in a javascript forum though... so for now, I'll just put my solution here in case anyone else is wanting/needing the same thing.
My only issue at this point is finding a way to keep the accordion menu unfolded to whatever page it's on. So that when they unfold one and click on a sub-level, it will be unfolded when it goes to that page still.
Adding target="_parent" to the links took care of opening the link in the navigation in the parent page.
Bookmarks