Lorenzo Vaina wrote:
No, client-side Javascript can neither read nor write files on a Web
server served from another domain.
Ok.
Yes, client-side Javascript can be made to "read" files from a Web server
served from the same domain that the Javascript was served from,
How please, if you are so patient?
Using the XML HTTP Request object available in IE or Gecko-based browsers.
Information on this is available at:
<url:
http://jibbering.com/2002/4/httprequest.html />
Or you can retrieve the content from the server into a hidden <iframe> and read
it from there:
<body onload="test();">
<iframe id="contentId" name="contentName" style="display:none;"
src="test.txt"></iframe>
<script type="text/javascript">
function test() {
var iframe;
if (document.getElementById && !document.frames) {
iframe = document.getElementById('contentId');
if (iframe &&
iframe.contentDocument &&
iframe.contentDocument.body &&
typeof iframe.contentDocument.body.innerHTML == 'string') {
alert('using getElementById: ' +
iframe.contentDocument.body.innerHTML);
}
} else if (document.frames) {
iframe = document.frames['contentName'];
if (iframe &&
iframe.document &&
iframe.document.body &&
typeof iframe.document.body.innerHTML == 'string') {
alert('using document.frames: ' + iframe.document.body.innerHTML);
}
} else {
alert('Browser does not support examining the content of an iframe');
}
}
</script>
--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq