|
-
Oct 4th, 2002, 03:18 PM
#1
Thread Starter
Fanatic Member
On error dont scream
Is there something like on error resume next in javascript?
Or.. is there a way to make sure an object exists? Like... if exists (btnSumbit){}......??
Thanks
"The difference between mad and genius is the success"
-
Oct 4th, 2002, 03:47 PM
#2
Stuck in the 80s
Not to my knowledge, no. But I don't know much about JS error handling.
-
Oct 4th, 2002, 03:48 PM
#3
Thread Starter
Fanatic Member
what about the second question??? Is there a way to know if a certain object exists before trying to do somethign with it?
"The difference between mad and genius is the success"
-
Oct 4th, 2002, 03:50 PM
#4
Frenzied Member
Originally posted by Andreex
what about the second question??? Is there a way to know if a certain object exists before trying to do somethign with it?
Code:
if (element){
alert('it exists');
}
I'll get back to you on the other in a sec.
Last edited by msimmons; Oct 4th, 2002 at 03:54 PM.
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 4th, 2002, 03:53 PM
#5
Frenzied Member
Code:
function stopErrors() {
return true;
}
window.onerror = stopErrors;
I think this is what you are looking for and exactly what I used it for as well... I had a problem with an element not being there in time so occasionaly would get the yellow triangle in the corner. I learned to ignore it but the users were freaked out. This is supposed to stop it. I don't think it does if you have your browser to give the pop up error though... can't remember.
hope that helps,
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 4th, 2002, 03:54 PM
#6
Thread Starter
Fanatic Member
nice... Thanks... This will do the trick....
"The difference between mad and genius is the success"
-
Oct 4th, 2002, 03:56 PM
#7
Thread Starter
Fanatic Member
hey.. I did the if (element){
alert('it exists');
and it sent me an error saying the element didnt exist ... why?
"The difference between mad and genius is the success"
-
Oct 4th, 2002, 04:04 PM
#8
Frenzied Member
Dont know if it will make a difference but in my code I have:
Code:
function loadPropertyInfoPage(){
if (!parent.frames[2].document.all.HotelID){
parent.frames[2].location.href = "propertyinfo.asp";
setTimeout("loadPropertyInfoPage()",1000);
} else {
getPassword();
}
}
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 4th, 2002, 04:06 PM
#9
Thread Starter
Fanatic Member
nope.. it doesnt work... isnt there a function or anything? That would be weird, dont you think?
"The difference between mad and genius is the success"
-
Oct 4th, 2002, 04:08 PM
#10
Frenzied Member
I don't understand what you mean. Its odd that it works for me though cos what I just posted is exactly what I have.
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 4th, 2002, 04:11 PM
#11
Thread Starter
Fanatic Member
well.. maybe I am misunderstanding.. or you are... but here is what I need.. 
Lets say... txtName is an object that does exist in the page and that... txtLastName is an object that doesnt exists... so
if I put...
if (txtLastName)
{
alert("it does exists")
}
else
{
alert("it does not exists")
}
but.. it sends me an error in the if line....
"The difference between mad and genius is the success"
-
Oct 4th, 2002, 04:15 PM
#12
Frenzied Member
yeah. thats what I use it for as well. Is that your code exactly? I think it should be:
if (document.txtLastName)
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 4th, 2002, 04:22 PM
#13
Thread Starter
Fanatic Member
there! It worked with the document. as the prefix!
THANKS
"The difference between mad and genius is the success"
-
Oct 4th, 2002, 04:23 PM
#14
Frenzied Member
lol... no problem, sorry I didn't think of that sooner.
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 5th, 2002, 05:25 AM
#15
Frenzied Member
I think that onerror thing may be IE only, not sure though. I think you can also use try...catch statements, I haven't tried though but I think they're used something like this:
Code:
try {
//The code goes here
}
catch (e) {
alert(e);
}
Or if you want to be selective:
Code:
catch (e if e == "ERROR_DESCRIPTION") {
}
-
Oct 7th, 2002, 09:31 AM
#16
Frenzied Member
Originally posted by Rick Bull
I think that onerror thing may be IE only, not sure though.
That is very possible. Most of my apps are IE only (as far as I know) as I was able to tell my clients what to do if they wanted to be a client but I am slowly starting to try my hardest to become compliant.
Michael
I'm off to GalahTech, hope to see you there.
If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.
-
Oct 8th, 2002, 06:02 AM
#17
Frenzied Member
Good boy It's not really that hard anyway, it's just that it's easy to pick up IE only habbits from other people.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|