[Web4lib] Javascript include question

Thomas Dowling tdowling at ohiolink.edu
Tue Jun 7 10:04:27 EDT 2005


Vishwam Annam wrote:
> Hello list,
> 
> 
> I would like to include an HTML file in javascript, like below:
> 
> if (case is true) document.write("<!--#include
> virtual='/ns4menu.html'-->") else document.write("<!--#include
> virtual='/menu.html'-->"). I know this doesn't work because these are
> SSIs, and not processed by client side scripting.  I wonder, are there
> any other ways to do this?
> 

"ns4menu.html," eh?  My general advice is to stop coddling NS4.  Send
good, modern markup; anyone still using that dog at this point has a
high tolerance for sites that don't look or work quite right for them.
(Sometime this summer, we're going to retire our last interfaces that
explicitly make allowances for NS4's incompetencies.)


But to answer your question, it seems like you either need a server-side
solution or a client-side solution.  If the condition you're testing for
is knowable on the server side, your SSI could be something like
'<!--#exec cgi="/script-that-decides.cgi" -->'  Otherwise, you could
send both versions of the menu and use client-side DHTML tricks to
display only the right one (with appropriate <noscript> actions, etc.).


-- 
Thomas Dowling
tdowling at ohiolink.edu


More information about the Web4lib mailing list