AlanDI1
Programmer
- Apr 20, 2003
- 56
Hi -
I have the following code that links to a specific location on my server. But the linked to location does not always exist and because of the way the link name is built I will not know that until the user clicks the link they want to go. So I have:
<script language="javascript">
// use java to check for existence of file then call url
function Graph_OnClick(urlPart1, theItem, urlPart2) {
window.onError = GraphCallError() ;
window.location.href (urlPart1 + theItem + urlPart2);
}
// location href failed so alert user
function GraphCallError (msg, url, linenumber) {
alert('Graph File Was NOT Found!');
}
</script>
The OnClick fires fine but the onError ALWAYS fires (whether or not the link exists) displaying the alert then the location.href fires regardless of whether or not the link exists.
What am I missng?
Thanks for you help
I have the following code that links to a specific location on my server. But the linked to location does not always exist and because of the way the link name is built I will not know that until the user clicks the link they want to go. So I have:
<script language="javascript">
// use java to check for existence of file then call url
function Graph_OnClick(urlPart1, theItem, urlPart2) {
window.onError = GraphCallError() ;
window.location.href (urlPart1 + theItem + urlPart2);
}
// location href failed so alert user
function GraphCallError (msg, url, linenumber) {
alert('Graph File Was NOT Found!');
}
</script>
The OnClick fires fine but the onError ALWAYS fires (whether or not the link exists) displaying the alert then the location.href fires regardless of whether or not the link exists.
What am I missng?
Thanks for you help