473,320 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Can I check for file existence in JavaScript?

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

Jul 23 '05 #1
4 2377
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.

Jul 23 '05 #2
In article <11**********************@o13g2000cwo.googlegroups .com>,
cn*****@nycap.rr.com enlightened us with...
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.

--
--
~kaeli~
What do they use to ship styrofoam?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4
Lee wrote:
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.


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?

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: McKirahan | last post by:
Is this a very good browser check? <html> <head> <title>wB.htm</title> <script type="text/javascript"> var adBtype = "??"; function wB() { if (document.getElementById && !document.all) {...
6
by: hectorlas | last post by:
I wasn't sure if this should go in a linux group or the C group, but here I am. How do I check for directory existence in C? It's gcc under Linux to be exact, and I don't have the option of...
2
by: www.MessageMazes.com | last post by:
Greetings, I'm experimenting with an ASP page that reads data from a file name that is passed to it as a parameter, as in this page, which works, because the "good" file exists. ...
52
by: paytam | last post by:
Hi all Can anyone tell me how can I check that a file exist or no.I mean when you use this commands FILE *fp; if(!fp) //Could not open the file doen't show why it can not open it,may be the...
25
by: pamelafluente | last post by:
Hi Guys, I have the following HTML code which is doing a GET to a page, say MyUrl.aspx : <body> <form name="form1" method="get" action="MyUrl.aspx" id="form1"> <input type="hidden"...
10
by: Dieter Pelz | last post by:
Hallo, what is the best way to check the installation of mfc80 and vcrt sidebyside assemblies? Best Regards, Dieter Pelz
14
by: Cylix | last post by:
As the title, How to do the ckecking in javascript? Thanks!
3
by: trint | last post by:
How can I do this with my c# code with my website(because the file is there, but the code doesn't return it)?: if(File.Exists(String.Format("~/images/categories/{0}", sFileName)) return...
0
by: MIRRA | last post by:
Hi I have a UNIX script which creates a report. In that script I have to define the java classpath. Also I need to check if the java classpath specified exists or not. Below is the command i use ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.