javascript checking for broken links

This is a discussion on "javascript checking for broken links" within the JavaScript Forum section. This forum, and the thread "javascript checking for broken links are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 20th, 2006, 06:26
New Member
Join Date: Jun 2006
Location: kuwait
Age: 24
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
javascript checking for broken links

dear profissionals

I need help in solving out a problem that kills me .....


I have an archiving system the we save a back up file daily with the following file path format : "C:\windows\...\06-07-2006.pdf " . the whole path is always the same and only the file name which is on a date format is daily being changed ... on our Intranet webpage we have a button to access the last version of this backup file and to avoid updating this button hyperlink daily , I used a javascript the makes the file name a variable called ( date ) and the file path become
" 'C:\windows\..\' + 'date' + '.pdf' " and the code is working perfectly that when the date of the computer changes daily the hyperlink is automaticly change


the problem now is that this backup file is only being saved and available on the end of our working hours before that anyone click on that button will get a windows pup-up message the this path is nout found ...

I want to know how can I used a javascript to check for the link first .. if it is available then fine , if it's not I want a wnidow.alert message to appear telling that the link is not updated yet , please try to visit this link after 3:00 pm

am beginner in javascript so please provide me the solution with an example code ....

many thanks in advance
Shido,
Reply With Quote

  #2 (permalink)  
Old Jun 20th, 2006, 18:52
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: javascript checking for broken links

Your basic problem here is that, for obvious security reasons, JavaScript is not allowed to access the client system. If it could, you could do all sorts of damage.

Your best bet is to get the JavaScript to check the time as well as the date and only update the link after some predetermined time.
Reply With Quote
  #3 (permalink)  
Old Jun 21st, 2006, 05:30
New Member
Join Date: Jun 2006
Location: kuwait
Age: 24
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: javascript checking for broken links

thanks for ur reply UKgeoff , but I already asked my Java Doctor at university and he told me that I can do it using the inputstream by using ( try & catch ) but he refused to show me how , he said remember that u need to import the needed libraries ..... please think with me how can we do it , and if javascript really can't do it then what is the best alternative ??


best regards
Reply With Quote
  #4 (permalink)  
Old Jun 21st, 2006, 08:58
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: javascript checking for broken links

You mention Java and importing libraries. Java is not the same as JavaScript. They are completely different languages.

JavaScript does have a try...catch functionality but it is for catching exceptions within the code that is being executed.

You are effectively clicking on a broken link and the server is telling the browser the requested file cannot be found.

At the moment, I cannot see any alternative to the suggestion in my previous post.
Reply With Quote
  #5 (permalink)  
Old Jun 21st, 2006, 10:00
New Member
Join Date: Jun 2006
Location: kuwait
Age: 24
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: javascript checking for broken links

I already thought before of what you told me but the problem is that it is not static , I mean every day they statistics and report department is publishing their reports and update the links in a deffirent time and that's what makes it difficult to use javascirpt for time in additon to date ,

but going back to try ..catch and exception .... u gave me agreat idea

now , let us see it this way ... the date will change and according to the date javascript I have the File path will be changed and the links will be updated even if the reports r not thier yet ..... now when we click on the un-updated links this will arise exception .... so we might use the try and catch to catch these exceptions and instead of getting the browser alert message we can use the javascript window.alert ........ I hope that what am saying is correct

I really do appreciate your help , thank you
Reply With Quote
  #6 (permalink)  
Old Jun 21st, 2006, 17:09
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: javascript checking for broken links

Try it and see. You have nothing to loose.

But I don't think it will work for the reasons I said in my previous post.
Reply With Quote
  #7 (permalink)  
Old Nov 8th, 2007, 07:19
Reputable Member
Join Date: Nov 2007
Location: India
Posts: 150
Blog Entries: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: javascript checking for broken links

You can customize the Error 404(File not found page) and insert the fololowing code into it:
Code: Select all
<script>
alert('The file you have requested is cannot be found at the moment.\nPlease try after 3.00 PM.Thank you')
</script>
Tutorials to create custom error pages can be found here and here

You may also benefit by looking at Link checking using JavaScript thread of mine
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)
Reply With Quote
Reply

Tags
javascript, checking, broken, links

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirect broken links Oak Search Engine Optimization (SEO) 8 Apr 18th, 2008 21:09
CSS links broken up and missing zippoloko Web Page Design 2 Apr 18th, 2008 01:36
[Tutorial -> Trick] Link checking using JavaScript (ny myself) RohanShenoy JavaScript Forum 7 Nov 8th, 2007 12:52
Javascript - Anti browser checking satimis JavaScript Forum 7 Aug 8th, 2007 15:43
Dreamweaver - Broken Links mark_88_turbo Graphics and 3D 5 Apr 8th, 2005 08:34


All times are GMT. The time now is 19:41.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43