www.webdeveloper.com
Results 1 to 10 of 10

Thread: window.onerror in Opera

  1. #1
    Join Date
    Nov 2002
    Location
    Flint, Michigan, USA
    Posts
    607

    window.onerror in Opera

    I am trying to use the following code to trap JavaScript errors. It seems to work well in IE and FF but not in Opera. I expect I must have turned it off somewhere in the "preferences" but I can't find where. I'm using Opera 10.10.
    Code:
    <script type="text/javascript">
     function Err() {
      alert('trapped');
      return true;
     }
     window.onerror=Err;
    </script>

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    It is as simple as that: Safari, Chrome, Opera and Konqueror do not support this event on JavaScript errors. Neither in IE nor in FF this event is complete implemented. IE and Firefox have trouble with JavaScript errors in the traditional event registration model.

    You should better use a debug tool, as a developer. Forget about onerror. It is inconsistent implemented along the browsers.

  3. #3
    Join Date
    Nov 2002
    Location
    Flint, Michigan, USA
    Posts
    607
    It is working in IE and FF, and it was working in Opera. I made some changes to the web page, installed a newer version of Opera, and then it doesn't work. I have trimmed the code to just the part in question and searched all of Opera's switches believing that the newer version changed something or I did it myself, but I can't find what. I'm hoping someone can point me to some, possibly hidden, option that I'm missing.

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428

  5. #5
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    that chart doesn't have any current browsers listed; chrome is 12 versions behind, ios is 2 versions, firefox is 3 version behind, etc...

    useless.

  6. #6
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by rnd me View Post
    that chart doesn't have any current browsers listed; chrome is 12 versions behind, ios is 2 versions, firefox is 3 version behind, etc...

    useless.
    The idea is that the new browsers still might have incomplete implementations of a method or another, and the answer to a question like "Why this method does not work in this browser?" is almost always: "Because this method does not work in this browser". If it does not work, it does not work. You may send it as a bug to the vendors.

    There might be cross-browser workarounds for a problem or another, but this one with onerror looks a little bit scope-less. maybe if the OP would detail end extend his aim, we might find a solve.
    Last edited by Kor; 05-31-2011 at 02:46 PM.

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Just a note: OP should consider the fact that browsers are in use always with at least 2-3 versions at the same time. Something might work in FF4, but not in FF 3.6, In IE9, but not in IE8, and so on.

    For instance, the fact that something does not work in Opera 10.10 is not so relevant. Opera has reached the version 11.11 already. Don't mention that it might be under Win, Mac, Linux...

  8. #8
    Join Date
    Nov 2002
    Location
    Flint, Michigan, USA
    Posts
    607
    Thank you all for your insights.

    For those who wanted more information: I worked for thirty-five years in a university IT department where I always had the newest, fastest, best-in-every-way computer and unbelievably fast internet connections. I had no need for anything great at home, so I was content with a Pentium II, Windows 98, on dial-up. Then I lost my job, my great office computer, and money to replace my home equipment. I'm not looking for sympathy, just explaining why I have such old stuff here. Unfortunately, the newer browsers will not run on my old machine.

    I have a web page which I wrote to help me test JavaScript while I'm trying to help people on the forums. I like it to easily tell me what is wrong without demanding that I go to an error console to see the messages. Opera is the ONLY browser where this fails; the following work perfectly:

    InternetExplorer 6.0.2800.1106
    FireFox 2.0.0.16
    Netscape 4.08 (WOW, can you believe it?)
    Netscape 7
    Mozilla 1.1
    SlimBrowser 5.0

  9. #9
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Quote Originally Posted by jalarie View Post
    I have a web page which I wrote to help me test JavaScript while I'm trying to help people on the forums. I like it to easily tell me what is wrong without demanding that I go to an error console to see the messages. Opera is the ONLY browser where this fails; the following work perfectly:
    examine the code at http://danml.com/sandbox/ and see how i catch errors to dump to the title, error console, and log tab.

  10. #10
    Join Date
    Nov 2002
    Location
    Flint, Michigan, USA
    Posts
    607
    To "rnd me" go thanks. Your try/catch works much better than the window.onerror that I had. Thank you to everyone for the help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles