iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old June 20th, 2006, 03:26 AM   #1
New Member
 

Join Date: Jun 2006
Location: kuwait
Age: 26
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Code_breaker is on a distinguished road
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,
Code_breaker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old June 20th, 2006, 03:52 PM   #2
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
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.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old June 21st, 2006, 02:30 AM   #3
New Member
 

Join Date: Jun 2006
Location: kuwait
Age: 26
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Code_breaker is on a distinguished road
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
Code_breaker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old June 21st, 2006, 05:58 AM   #4
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
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.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old June 21st, 2006, 07:00 AM   #5
New Member
 

Join Date: Jun 2006
Location: kuwait
Age: 26
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Code_breaker is on a distinguished road
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
Code_breaker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old June 21st, 2006, 02:09 PM   #6
Most Reputable Member
 

Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,307
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 ukgeoff has a spectacular aura about ukgeoff has a spectacular aura about
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.
ukgeoff is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old November 8th, 2007, 04:19 AM   #7
Reputable Member
 

Join Date: Nov 2007
Location: India
Posts: 150
Blog Entries: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 RohanShenoy is on a distinguished road
Re: javascript checking for broken links

You can customize the Error 404(File not found page) and insert the fololowing code into it:
Code:
<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
RohanShenoy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
javascript , checking , broken , links


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 April 18th, 2008 06:09 PM
CSS links broken up and missing zippoloko HTML, XHTML and CSS 2 April 17th, 2008 10:36 PM
[Tutorial -> Trick] Link checking using JavaScript (ny myself) RohanShenoy JavaScript 7 November 8th, 2007 09:52 AM
Javascript - Anti browser checking satimis JavaScript 7 August 8th, 2007 12:43 PM
Dreamweaver - Broken Links mark_88_turbo Graphic Specifics 5 April 8th, 2005 05:34 AM


Search Engine Optimization by vBSEO 3.2.0 RC8