Results 1 to 17 of 17

Thread: On error dont scream

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843

    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"

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Not to my knowledge, no. But I don't know much about JS error handling.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    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"

  4. #4
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  5. #5
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    nice... Thanks... This will do the trick....
    "The difference between mad and genius is the success"

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    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"

  8. #8
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    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"

  10. #10
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    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"

  12. #12
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2001
    Posts
    843
    there! It worked with the document. as the prefix!
    THANKS
    "The difference between mad and genius is the success"

  14. #14
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  15. #15
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    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") {
    }

  16. #16
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    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.

  17. #17
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    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
  •  



Click Here to Expand Forum to Full Width