Can I check for file existence in JavaScript?

C

Christopher Nelson

I have a multi-page site that I want to be able to resume at the same
page if the user leaves and comes back later (say, days later). I'm
thinking that I'll set a cookie as each page is displayed and when the
main/first page displays, I'll look for the cookie and open the page it
names. If a new version of the site omits a page that used to exist or
if the cookie somehow becomes corrupt, I don't want to display an error
when I try to open the page. Can I check for the existence of page
(CGI file) from JavaScript so I don't try to display the page if it
won't be found?

Chris
 
L

Lee

Christopher Nelson said:
I have a multi-page site that I want to be able to resume at the same
page if the user leaves and comes back later (say, days later). I'm
thinking that I'll set a cookie as each page is displayed and when the
main/first page displays, I'll look for the cookie and open the page it
names. If a new version of the site omits a page that used to exist or
if the cookie somehow becomes corrupt, I don't want to display an error
when I try to open the page. Can I check for the existence of page
(CGI file) from JavaScript so I don't try to display the page if it
won't be found?

Process the cookie on the server side, where you can easily check
to see if the page exists, has been renamed, etc.
 
K

kaeli

I have a multi-page site that I want to be able to resume at the same
page if the user leaves and comes back later (say, days later). I'm
thinking that I'll set a cookie as each page is displayed and when the
main/first page displays, I'll look for the cookie and open the page it
names. If a new version of the site omits a page that used to exist or
if the cookie somehow becomes corrupt, I don't want to display an error
when I try to open the page. Can I check for the existence of page
(CGI file) from JavaScript so I don't try to display the page if it
won't be found?

A page on the server?
Kind of.
You can either use the xmlhttprequest object or you can use dynamic
javascript that gets its source from a sever-side process. That process would
check for the file and return the proper script.
Though if you're using server-side scripting, you might as well use it for
all of it, not just part of it, in this case.

--
 
C

Christopher Nelson

Lee said:
Christopher Nelson said:

Process the cookie on the server side, where you can easily check
to see if the page exists, has been renamed, etc.

Great idea! Thanks.

I realize this is c.l.js but can someone point me at resources for
manipulating cookies from C on the server?
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top