SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Check for URL exists
-
Aug 20, 2001, 18:25 #1
- Join Date
- May 2001
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Check for URL exists
How to check whether an HTML file with a specified URL exist on the web server using javascript and if not redirect to an alternative URL
Thanks in advance
ipromote
-
Aug 21, 2001, 10:33 #2
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi ipromote,
You could try something like:
if (document.URL != something) redirect2SomewhereElse();
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Aug 21, 2001, 16:57 #3
- Join Date
- May 2001
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That's not exactly I want.
The above code will help me find out whether the URL's match but don't help me determine whether the file that is being represented by the URL actually exists.
Any more ideas ?
-
Aug 21, 2001, 18:20 #4
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi ipromote,
Perhaps you'd best explain yourself more. Are you trying to determine if a user-entered URL is valid; that is, exists? The only way I know of is to actually go out there and see if you connect or get a 404 -- which means server-side.
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Aug 22, 2001, 05:51 #5
- Join Date
- Jul 2001
- Location
- Scotland
- Posts
- 4,836
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i dont think youll be able to do it client side, but i have an idea to do it server side usng asp anda compents that comes with IIS (XMLHTTP) if you interested
either post here or pm me
-
Aug 22, 2001, 18:28 #6
- Join Date
- May 2001
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Actually what I would like to achieve here is to fetch some content onto a page in all circumstances.
Currently I have a perl script that fetches the content to all my pages through IFRAME or Javascript depending on whether the browser is IE or Netscape. But some times when cgi script server goes down the IFRAME tag still tries to fetch the URL and comes up with page not found error, instead I would like to call a javascript to get content from another source.
For this I should know whether the Perl script is accessible at any point.
Any clues ?
-
Aug 23, 2001, 09:19 #7
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
cgi script server goes down the IFRAME tag still tries to fetch the URL and comes up with page not found error,
The only thing you can do for the iframe is assign a function to the src -- <iframe src='javascriptage2Display()'....> -- the function should return a valid page to load.
At present, I'm presuming your cgi is processing the page somehow; well, when it gets the 'page not found' error (the perl people should know how) you substitute the other page and return it.
VinnyWhere the World Once Stood
the blades of grass
cut me still
Bookmarks