[thelist] using javascript to create an include?

Keith cache at dowebs.com
Thu Jan 3 00:34:07 CST 2002

> what I want to do is create a javascript that says "if it is
> this particular day, load this html".  I would do this in an
> include, since we're talking an article here, but of course an
> include is server side and javascript is client-side.

I use javascript includes, they're called client side includes. For the 
scenario you describe place something like the following script 
block in your body where you want the include to appear:

if (today is){   // use some method for if today
document.write('<script src="todays.js"></scr'+'ipt>')

Then on todays.js return a document.write like so

document.write('The cow'+
'jumped over the'+

You can nest document.writes in document.writes including a write 
to an external js file. In fact you can nest cgi includes the same way, 
for example:

document.write('<script src="some.cgi?'+qs+'"></scr'+'ipt>')

and give the cgi the query string to determine what to return as 
document.write output back to the page as an include. This allows a 
"static" page from serverA to display, as an include, dynamic 
content from serverB.


More information about the thelist mailing list