364,083 Members | 5803 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Can I check for file existence in JavaScript?

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

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


Lee
P: n/a
Lee
Christopher Nelson said:[color=blue]
>
>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?[/color]

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

kaeli
P: n/a
kaeli
In article <1114624743.685696.104010@o13g2000cwo.googlegroups .com>,
cnelson@nycap.rr.com enlightened us with...[color=blue]
> 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?[/color]

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

Christopher Nelson
P: n/a
Christopher Nelson
Lee wrote:[color=blue]
> Christopher Nelson said:[color=green]
> >
> >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?[/color]
>
> Process the cookie on the server side, where you can easily check
> to see if the page exists, has been renamed, etc.[/color]

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

Post your reply

Help answer this question



Didn't find the answer to your JavaScript / Ajax / DHTML question?

You can also browse similar questions: JavaScript / Ajax / DHTML