Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to TRAP dnserror / Page Not Found Error Client side

Status
Not open for further replies.

mac4511

Technical User
Apr 26, 2001
14
GB
Hi I need help to find a way to trap failed links to pages which have been deleted. Bad links normally show a Web page with title Cannot Find Server - which seems to be an IE 5 generated page. I want to be able to either substitute my own page or trap the error and redirect back to a good page.

I have to do this WITHOUT using perl or cgi as it needs to be client side only and its got to work in ie4+ 5+ and 5.5+. I have looked at the html "onerror" event but thats only good for bad scripts not missing files.

Any ideas please.
 
you can do this with your webserver, most likely and more easily, but... but, the only way to do this would be to call a function that checked the link in a hidden iframe, then using the onreadystate== "complete" property of the iframe, you could check the page once its done loading. if its title is whatever the error ones are, then you can send the user to a a page of your choice, otherwise, send him to the page the clicked on. luciddream@subdimension.com
 
Hi guys, thanks for the help so far. One thing I forgot to make clear is that this isnt running on a server - its working on a standalone laptop PC so no server functions available. The destination url's are actually PDF files which load into a large frame next to the selection section in a narrow frame next to it. For direct file access I have a key in box for the doc. filename and the .pdf is appended to it as a complete path / url. This works fine as long as the typed name is exactly right.

Another thought I just had was, is it possible to do something like IF EXISTS... to check the filename exists in the path, therefore solving the problem...if it aint there show a message or page instead.
I believe it can be done in Visual Basic but can it be done in Javascript or VBScript or even HTML. I reckon this might be the best solution - any ideas please ?

I've been experimenting with the idea of doc titles and I can easily detect the file in the frame if it is a pdf, but if it fails the Not Found window doesnt show in the frame for some reason. I havent tried hidden frames yet.. does it have to be an IFRAME ?

All help appreciated

Thanks
mac


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top