By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,187 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,187 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2

P: n/a


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/...d/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
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

P: n/a
Marcel Brekelmans wrote:
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.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #4

P: n/a
For IE you can use download behaviuor:
http://msdn.microsoft.com/library/de...asp?frame=true

--
Joe

"Marcel Brekelmans" <ne********@marcel-art.com> wrote in message
news:HS********************@amsnews02.chello.com.. .
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?

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more JavaScript / Ajax / DHTML Questions on Bytes