I want to include an external file with javascript, depending on condidtions. browser detection stuff. thephp syntax would be <?php readfile("external.file") ?> and SSI would be <!--#include file="external.file" -->, but is there a way to do it in JavaScript?

sorry if this question has been asked, i did search with no luck.

requestcode

02-01-2004, 12:20 AM

The only external file you can include with javascript is an external javascript file with an ".js" extension. The file must contain javascript only. Check this link out for more info:
http://www.javascriptkit.com/javatutors/external.shtml

COBOLdinosaur

02-01-2004, 12:28 AM

You can try populateing a layer with XMLHTTP.

You can use this script to bring external include files into a layer in the page, or insert the text inline:

If the string returned from the call contains valid HTML it will be rendered, otherwise it will display as plain text.

Does not work for older browser like Netscrap 4.x that do not know what XML is.

It can produce an alert if the user security settings have activeX disabled

=======================================================

I used this script successfully with a href="#"OnClick... option.. its working fine but when another page is again loaded with the same href="#"OnClick... the cursor does not move at the top... so the page is not displayed from the top. we have to manually scroll the page ... how to get rid of this??? Please help...