Re:javascript file check

by JimMenees(at)aol.com

 Date:  Sat, 27 Apr 2002 09:30:07 EDT
 To:  hwg-languages(at)hwg.org
 Cc:  clarencej(at)cantv.net
  todo: View Thread, Original
Clarence,
Just thinking aloud, what happens when you load a web page delivered by an
online server? It delivers content: html tags, text, css files, javascript
files, applet classes and image files.  No connection, then no delivery of
files (to the user's temporary internet folder).

So my thoughts are that you create your html page with a link to a file
(image, css, whatever) that can only be obtained if the user is connected to
the net.  It won't be something that will create an error, just either be
stored in the user cache or not.  Then, you create a script to see if that
file exists. If "no", then the javascript in your html page will send up an
alert box or error or whatever.

At first I thought more along the lines of a small java applet in your page
which would call the user's system its "home" and therefore be able to check
in the temp internet folder to see if a file exists.  This would probably
work and would have to interact with javascript... a lot of coding in other
words.

Then I thought along the lines of a javascript upload files script.  I know
nothing about that aspect of the code, but I do know you can create some JS
code to upload files from a user's system.  What happens if they don't
exist??

I found a whole thread of potential solutions at:
    http://www.faqts.com/knowledge_base/index.phtml/fid/177

which should offer you enough code to write a script to:
    1. determine if cached file 'x' exists on the user's system
     2. throw up an alert if it does not exist.

It would seem that this unique file 'x' will have to be a file that the user
can only get from a live connection; AND, cannot be saved until later.
    ie: what happens when the user finally does get a live connection, and the
object is actually obtained and stored in the cache and the user does not
empty their cache???

ALong those lines, it could be a cookie which is sent and then deleted via a
live connection.  If cookie does not exist, then alert("No Connection") and
set a time to live limit on the cookie.   This might require a script that
compares the i.d. of a local host server to the name of a live-connnection
server.
if (localhost server != liveconnect hostserver)
    alert("You are not Connected);

Hope this has helped generate some ideas and suggestions:
   1. test for local file
   2. test by using a time-limited cookie
   3. test by comparing the host-server name;

I would hope that among the three options, somethign would make sense and
could be coded/designed to meet your needs!!

Good luck!!!  

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA