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.
|
|
|
|
|
![]() |
||
javascript checking for broken links
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
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, |
|
|
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
Re: javascript checking for broken links
You can customize the Error 404(File not found page) and insert the fololowing code into it:
You may also benefit by looking at Link checking using JavaScript thread of mine
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)
|
![]() |
| Tags |
| javascript, checking, broken, links |
| Thread Tools | |
|
|
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 |