Why does it seem impossible to read a simple, small textfile on the server with client-side code?

M

Marcel Brekelmans

Hi,

This is my situation:

My ISP doesn't allow me the execute server-code. So, no ASP or otherwise.As
a small compensation, they run some CGI scripts that we can use. With one of
these scripts I maintain a set of counters, one on each of my HTML pages
that they host. It is all very basic, the files are no more then textfiles
that ONLY contain the number of hits, as a characterstring. The filename is
free for me to choose, the extension MUST BE "xbm". So, for the counter on
the Links page that has had 248 hits uptill now, the file would be
"links.xbm", with the contents "248". A file with length 4 (EOL is 1
character). What I would like is to be able client-side to read these
counterfiles. But as far as I can tell it is not possible.

One trick in Javascript would be to create an extra, hidden, frame on my
page and load the file into that frame. The frame contents would then
reflect the contents of the file. Unfortunately, since the file's extension
is 'xbm', the file is not recognized as textual, and the frame will contain
the file as a <IMG> tag.

In VBScript you could think that the FileSystemObject could do the trick.
However, that acts on the local system, i.e. the pc of the client and not on
the server: an URL is not a valid filepath. Besides, it will generate an
Active-X warning and I don't want that.


Any help?
 
E

Evertjan.

Marcel Brekelmans wrote on 24 jan 2004 in
microsoft.public.scripting.jscript:
Hi,

This is my situation:

My ISP doesn't allow me the execute server-code. So, no ASP or
otherwise.As a small compensation, they run some CGI scripts that we
can use. With one of these scripts I maintain a set of counters, one
on each of my HTML pages that they host. It is all very basic, the
files are no more then textfiles that ONLY contain the number of hits,
as a characterstring. The filename is free for me to choose, the
extension MUST BE "xbm". So, for the counter on the Links page that
has had 248 hits uptill now, the file would be "links.xbm", with the
contents "248". A file with length 4 (EOL is 1 character). What I
would like is to be able client-side to read these counterfiles. But
as far as I can tell it is not possible.

One trick in Javascript would be to create an extra, hidden, frame on
my page and load the file into that frame. The frame contents would
then reflect the contents of the file. Unfortunately, since the file's
extension is 'xbm', the file is not recognized as textual, and the
frame will contain the file as a <IMG> tag.

In VBScript you could think that the FileSystemObject could do the
trick. However, that acts on the local system, i.e. the pc of the
client and not on the server: an URL is not a valid filepath. Besides,
it will generate an Active-X warning and I don't want that.

IE:

function getUrl(url) {
var http = new ActiveXObject("microsoft.xmlhttp");
http.open("GET",url,false);
http.send();
return http.responseText;
}

Yes, you will get a warning, but clientside javascript is possible
 
M

Martin Honnen

Marcel Brekelmans wrote:

My ISP doesn't allow me the execute server-code. So, no ASP or otherwise.As
a small compensation, they run some CGI scripts that we can use. With one of
these scripts I maintain a set of counters, one on each of my HTML pages
that they host. It is all very basic, the files are no more then textfiles
that ONLY contain the number of hits, as a characterstring. The filename is
free for me to choose, the extension MUST BE "xbm". So, for the counter on
the Links page that has had 248 hits uptill now, the file would be
"links.xbm", with the contents "248". A file with length 4 (EOL is 1
character).

And the ISP does provide the CGI to have counters but it doesn't provide
tools or doesn't explain how to include a counter value in an HTML page?
Tell them to associate the .xbm suffix with text/plain and you can use
an iframe to include that value.
Or use an external counter service, I guess there are still free counter
services around.
What I would like is to be able client-side to read these
counterfiles. But as far as I can tell it is not possible.

Some browsers do provide features/apis to client side JavaScript
allowing to read from a URL on the same server but how would that help
on the Web for users with JavaScript disabled or of browsers not
supporting that?
As for reading values, for IE5+/Win you can use the download behaviour,
see the section about that in
http://www.faqts.com/knowledge_base/view.phtml/aid/1268/fid/126
for IE5+/Win and Netscape 6+ you can also use the XMLHttpRequest and
read the responseText property, see the FAQ
http://jibbering.com/faq/#FAQ4_38
 
R

Randy Webb

Marcel said:
Hi,

This is my situation:

My ISP doesn't allow me the execute server-code. So, no ASP or otherwise.As
a small compensation, they run some CGI scripts that we can use. With one of
these scripts I maintain a set of counters, one on each of my HTML pages
that they host. It is all very basic, the files are no more then textfiles
that ONLY contain the number of hits, as a characterstring. The filename is
free for me to choose, the extension MUST BE "xbm". So, for the counter on
the Links page that has had 248 hits uptill now, the file would be
"links.xbm", with the contents "248". A file with length 4 (EOL is 1
character). What I would like is to be able client-side to read these
counterfiles. But as far as I can tell it is not possible.

One trick in Javascript would be to create an extra, hidden, frame on my
page and load the file into that frame. The frame contents would then
reflect the contents of the file. Unfortunately, since the file's extension
is 'xbm', the file is not recognized as textual, and the frame will contain
the file as a <IMG> tag.

In VBScript you could think that the FileSystemObject could do the trick.
However, that acts on the local system, i.e. the pc of the client and not on
the server: an URL is not a valid filepath. Besides, it will generate an
Active-X warning and I don't want that.

http://www.jibbering.com/faq/#FAQ4_38

Either an HTTPRequest object (limited browser support - still an ActiveX
warning) or a Java applet. The above URL explains.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top