Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to include html with minimal write() calls

Status
Not open for further replies.

raindogs

Programmer
Nov 23, 2005
27
US
I'm setting up a library of html content to be included across various pages, and I'd like to use JavaScript to do it. I know I can do a standard src() call in the HTML page and then have the include written out as JavaScript with a bunch of write() calls. What I'm looking for is something akin to Perl's "here document", where I can just place on write() call at the top of each of my JavaScript includes and then have it pull in whatever html I write within that until it's closed. Is there a way to do this?
 
Is there a way to do this?

Yes, but it's very NOT recommended. Users can turn javascript off so it's best not to depend on it for things like writing out page content.

The sort of behavior that you're explaining is exactly what server side includes were made for. You might want to read up on them and consider using them instead.

Here's a bit of information about them:


You'll find loads more information about them on google as well.

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top