SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question supressing errors

    Hi
    I am not much of a JavaScript programmer. I want to know how can I supress any errors that come in my script, like if there are some errors in my script like syntax errors or runtime errors, the browser(MSIE or NN) display a dialog stating that there are errors in script.
    I don't want them to display that.
    I know that there's an event


    Code:
     window.onerror = some function
    this event is raised if there's any error in the script, but what should I put in place of some function so that the error dialogs in the browser doesn't appear.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the MS dhtml ref:
    To suppress the default Microsoft® Internet Explorer error message for the window event, set the returnValue property of the event object to true or simply return true in Microsoft JScript®.

    The onerror event fires for run-time errors, but not for compilation errors. In addition, error dialog boxes raised by script debuggers are not suppressed by returning true. To turn off script debuggers, disable script debugging in Internet Explorer by choosing Internet Options from the Tools menu. Click the Advanced tab and select the appropriate check box(es).

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe the cross-browser way would be

    window.onerror = function() { return true; };
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    To suppress the default Microsoft® Internet Explorer error message for the window event, set the returnValue property of the event object to true or simply return true in Microsoft JScript®.

    The onerror event fires for run-time errors, but not for compilation errors. In addition, error dialog boxes raised by script debuggers are not suppressed by returning true. To turn off script debuggers, disable script debugging in Internet Explorer by choosing Internet Options from the Tools menu. Click the Advanced tab and select the appropriate check box(es).
    The script debugger can be turned off for the local browser but how to turn it off in the visitor's browser who is visiting the website?? I read somewhere that its possible to tweak some settings of IE as well as NN through JavaScript. So how do I go about that.

    As for returning true for the window.onerror event, I've tried both true & false as well as continue but the dialog still pops open saying that there are some errors in script & would I still like to run it.

    So what do I do now??
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!

  5. #5
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wait...it gives an error and asks if you'd like to run it? That sounds like you've got a non-terminal loop or something.

    Why don't you try to fix your errors first, before masking them?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  6. #6
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the only time i've needed to supress an error was when I had code coming from a remote server for ads that I had no control over.

    I guess it could be useful if being viewed in older browsers though.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  7. #7
    SitePoint Wizard silver trophybronze trophy asp_funda's Avatar
    Join Date
    Jun 2003
    Location
    ether
    Posts
    4,479
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I went over again & again through the code & I can't figure out where the error is. It was running fine earlier & I hadn't made any changes to the code. The code is here:-

    Code:
    function openWin(w, h, t, l)
    {
    var abc = window.open("", "abc", "width="+w+",height="+h+",left="+l+",top="+t+",toolbar=1,scrollbars=1,resizable=1");
    }

    & I am putting the following in a button to open the window:--

    Code:
    onClick="openWin(350, 200, 100, 100);"

    Now this thing was working fine earlier but 2-3 days ago, it started giving errors.
    So what could be the problem.
    I have to look for some way stop errors from being raised.
    Our lives teach us who we are.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Me - Photo Blog - Personal Blog - Dev Blog
    iG:Syntax Hiliter -- Colourize your code in WordPress!!


Bookmarks

Posting Permissions

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