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:)
Printable View
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:)
Not to my knowledge, no. But I don't know much about JS error handling.
what about the second question??? Is there a way to know if a certain object exists before trying to do somethign with it?
Quote:
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?
I'll get back to you on the other in a sec.Code:if (element){
alert('it exists');
}
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.Code:function stopErrors() {
return true;
}
window.onerror = stopErrors;
hope that helps,
Michael
nice... Thanks... This will do the trick.... :)
hey.. I did the if (element){
alert('it exists');
and it sent me an error saying the element didnt exist:(... why?
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();
}
}
nope.. it doesnt work... isnt there a function or anything? That would be weird, dont you think?
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
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....
yeah. thats what I use it for as well. Is that your code exactly? I think it should be:
if (document.txtLastName)
there! It worked with the document. as the prefix!
THANKS
lol... no problem, sorry I didn't think of that sooner.
Michael
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:
Or if you want to be selective:Code:try {
//The code goes here
}
catch (e) {
alert(e);
}
Code:catch (e if e == "ERROR_DESCRIPTION") {
}
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.Quote:
Originally posted by Rick Bull
I think that onerror thing may be IE only, not sure though.
Michael
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.