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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

on window error refresh window script 1

Status
Not open for further replies.

codeone

Programmer
Mar 25, 2003
343
US
wondering how to tell if the window throws up an error and if so it would then refresh the page or at least attempt to...

I tried a couple of ways I thought I knew and none of them worked for me, I am coding strictly for IE5 and better, so crossbrowser is not a concern... all help is appreciated

thanks

co

__________________________________________________________
"The only difference between me and a mad man is that I'm not mad."
- Dali
 
Code:
window.onerror = err;

function err(msg) {
   alert("There has been an error:\n\n"+msg);
   window.location.reload(true);
}
 
nice!

thanks alot!

__________________________________________________________
"The only difference between me and a mad man is that I'm not mad."
- Dali
 

The window.onerror is a good solution. I was toying with this one, but it's nowhere near as neat:

Code:
<script type="text/javascript">
try {
   // all your js code goes here
}
catch (err) {
   alert(err);
}
</script>

But I think I'd stickl with what you have already ;o)

Dan
 
yeah that code minus the alert is perfect for what I needed, had a dynamic menu throwing up errors if the users mouse was sitting over top of the buttons which called them to be visible, the problem is the object was not present because it wasnt threw loading...so now if this is to occur the page auto reloads and walla no error at all.

perfect!

__________________________________________________________
"The only difference between me and a mad man is that I'm not mad."
- Dali
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top