Forum Moderators: open

Message Too Old, No Replies

Multiple file HTML question

can you call a <div> from another source file?

         

mcvoid

9:01 pm on Apr 24, 2006 (gmt 0)

10+ Year Member



ok, people, here's the conditions for my question.
1. I have pieces of HTML files that are identical from page to page (ie: menu bars)
2. I'm looking for a way to keep the code in one file, for easy updating
3. I'm against Frontpage's shared borders to get the job done because I'm moving to a server without frontpage extensions
4. I'm against using frames because I'd like flexible css positioning for these elements. It still remains an option though.
5. I want to keep it as simple as possible, so I'd like to stay away from scripting, although php might be a viable option if all else fails.

So here's the question I've been kicking around:
Can I have a section of a page in a separate HTML file that can be embedded into a main HTML file? Something along the lines of <div id='menubar' src='menubar.html'>
I can see that you can use different namespaces in XHTML; Could I use that feature to insert code in another XHTML namespace instance? Something like this inside the body tag:
<body>
...
<html xmlns="blah blah..." src="menubar.html">
</html>
...
</body>

whoisgregg

9:10 pm on Apr 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Inline attachment of HTML is not part of the HTML spec like inline attachment of images.

However, what you are trying to accomplish is easily done using any server side language. PHP includes, SSI, ASP, whatever.

Here's a thread in the PHP Library [webmasterworld.com] that may be of assistance: A dynamic site in 2 minutes [webmasterworld.com]

mcvoid

9:21 pm on Apr 24, 2006 (gmt 0)

10+ Year Member



I was reading the XHTML spec and it mentioned using other XML namespaces with their own markup inline with HTML, so I was just wondering if this was a possibility. PHP was my backup plan, though.
Wouldn't it be nice if you COULD import external code as part of the HTML specification, though? I think with the increasing separation and modularity of different aspects of web design, this might turn out to be a helpful feature in the future. Modular HTML...

Robin_reala

11:40 am on Apr 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope, namespaces isn't what you want. PHP is pretty much ideal for you I'd guess.

As for client-side HTML insertion, that's what the <object> element is for (or alternatively, because we live in an imperfect world, <iframe>).

mcvoid

1:21 pm on Apr 25, 2006 (gmt 0)

10+ Year Member



Cool. There goes another crazy idea... but php is easy enough. Thanks, guys!