Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>Check to see if a page exists in Javascript.

Check to see if a page exists in Javascript.

MikoLone
11-22-2004, 10:21 PM
I am wondering if you can check if a page exists and if it doesn't to handle for that.

for example. I want to know if the woowho.htm page is in the secure folder. so maybe I check

if(secure/woowho.htm exists) {
location.href woowho.htm
}else{
location.href = oops.htm
}

I guess I want to know if I get a error 404 from going to the woowho.htm page.

Thanks.

Michael

joh6nn
11-22-2004, 10:42 PM
this might be possible on newer browsers. but before i start giving you the code that MIGHT work on newer machines, let me ask more specifically what you're trying to do. this is just a piece of the project, it sounds like. what's the whole project? in what context are you trying to use this?

jbot
11-23-2004, 09:45 AM
this might be possible on newer browsers.

it might? don't see how, unless you're gonna use XML over Http to ask a serverside script to check, and then return a yay or nay.

joh6nn
11-23-2004, 07:07 PM
that's what i was thinkin' of alright, but since i've never had need of that method, i'm not sure how it will react to a 404. on the other hand, depending on what he's trying to do, there might be simpler ways to go about this.

glenngv
11-24-2004, 05:36 AM
You can use XMLHTTP in javascript to check the returned HTTP status of the request.

But as joh6nn said, there might be simpler ways to do this, specifically without any scripting involved. For instance, you can set custom 404 page in the server, so any request for non-existing pages, the custom 404 page will be displayed.

jbot
11-24-2004, 09:13 AM
i got the impression he was wanting to check for the existence of external pages, and would needed to have pinged the third party's server. hence using JS to call Perl or PHP.


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

Drag n drop Thumbnail Images to iFrame, with Original Size
Help with an online order form using drop down boxes
variable scope
absolutely positioned scrollable area code wont work for me...
multiple slideshows on one page with linkable pics?
Math
Get an Error I don't recognize?

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics