onerror - help required

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maanand
    New Member
    • Dec 2007
    • 3

    onerror - help required

    [HTML]<html>
    <head>
    <script type="text/javascript">

    onerror=handleE rr;
    var txt="";

    function handleErr(msg,u rl,l)
    {
    txt="There was an error on this page.\n\n";
    txt+="Error: " + msg + "\n";
    txt+="URL: " + url + "\n";
    txt+="Line: " + l + "\n\n";
    txt+="Click OK to continue.\n\n";
    alert(txt);
    return false;
    }
    function message()
    {
    adddlert("Welco me guest!");
    }
    </script>
    </head>

    <body>
    <input type="button" value="View message" onclick="messag e()" />
    </body>[/HTML]

    This code returns
    "object expected" in IE and
    "adddlert not defined" in Mozilla Firefox

    Question:

    I want the data "adddlert not defined" to be displayed in IE too. How can i get that information in IE ?
    Last edited by gits; Dec 11 '07, 07:26 AM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    welcome to TSDN ...

    i think you cannot control what error-message the js-runtime throws ... so without checking and replacing it explicitly i'm quite sure that there is no possibility to control the msg.

    kind regards

    Comment

    • maanand
      New Member
      • Dec 2007
      • 3

      #3
      Do you have any suggestion to explicitly track the information?
      Can't java runtime throw same error message in mozilla and IE?

      Any help on this will be appriciated ..
      thanks Gits for your kind reply ;-)

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        hmmm ... you would have to use a try-catch statement and catch and handle any error for yourself ... its quite a task :) if you have that requirement i think there is no chance to do it another way ... otherwise i think it's quite useless ... because you could simply use the messages of the js-runtime where IE gives you the bad ones ;) ...

        kind regards

        Comment

        • maanand
          New Member
          • Dec 2007
          • 3

          #5
          Hi Gits,

          My intention is to try and find the javascript error that happens and log the same.
          The error happens very rarely , so i would want the error to be logged whenever it happend so that i can find and solve it.
          Since i dont exactly know where the error causng code is, I cant jus try catch :(

          So any information on logging the js errors is also welcome

          thanks again

          anand

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            as i said ... you are then bound to that what the runtime gives you ... and have to live with IE's often useless messages and wrong line-numbers ...

            kind regards

            Comment

            Working...