/    Sign up×
Community /Pin to ProfileBookmark

Prevent error message when dyn. menu is not loaded completely

On my site and others I have the problem that loading a dynamic menu takes some time. If a visitor clicks on anywhere before the menu is loaded completely a javascript error message shows up telling the visitor that “menu[…].o.ref is not an object”. I have used the script “Cascading Menu” by Angus Turnbull.

Can anybody help? Thanks!

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryAug 19.2003 — You can use [b]window.onerror = null[/b] to suppress error messages, if that's what you want.

Adam
Copy linkTweet thisAlerts:
@AlexauthorAug 19.2003 — Hi Adam,

this could be ok for smaller sites but when using a lot of javascript I need the error messages to prevent any bugs within the site...

-- Alex
Copy linkTweet thisAlerts:
@AlexauthorAug 27.2003 — Unfortunately I stil have the problem mentioned in my first thread. Maybe somebody other has an idea how to prevent this error message?

How can I found out when the menu has been loaded completely? Then I could disable the javascript error messages completely until the menu has been loaded and the enable the javascript error messages again.

Does anybody know a solution for this?

Thank you very much in advance!
Copy linkTweet thisAlerts:
@Khalid_AliAug 27.2003 — what you can do is suppress error messages once the menu is loaded completely.

http://www.webapplikations.com/pages/html_js/document/SuppressError.html

the solution above is a variation of the solution suggested above,it s up to u how you implement it in your code,it should work.
Copy linkTweet thisAlerts:
@AlexauthorAug 28.2003 — Thanks Khalid,

but that's more or less the same like Adam already posted.

How can I enable the error messages again when using your script?

Is there a possibility to return to the browsers default settings to display the error message again?
Copy linkTweet thisAlerts:
@AdamGundryAug 28.2003 — IIRC, changing the error handler to make it return false should make the browser log errors normally.

Adam
Copy linkTweet thisAlerts:
@Khalid_AliAug 28.2003 — Ok I have not tried this but let me know of the results.

This is what you should do.

logic.

  • 1. suppress error displaying before the menu starts loading


  • 2. allow errors once the menus is loaded.


  • 3.implementation

    declare a global variable say

    var menuLoaded = true;

    now locate the function that starts menu loading

    the very first thing in that function

    window.onerror = errorHandler;


    now I am hoping it will work,

    at the end of the functionthat calls the menu, set the falue to false

    menuLoaded = false;

    add this again

    window.onerror = errorHandler;


    below is the error handler function put it any where.

    function errorHandler(){

    return menuLoaded;

    }


    lol...I think it should work.
    Copy linkTweet thisAlerts:
    @AlexauthorAug 28.2003 — Hi Khalid,

    thanks for that hint, I will try out...
    Copy linkTweet thisAlerts:
    @AlexauthorAug 28.2003 — Thank you yery much for your support!
    Copy linkTweet thisAlerts:
    @wallacedmAug 28.2003 — My advice - don't do the error handler thing, because sometimes there might be real error that you want to trap.

    Add the following code into whichever Javascript function requires all the bits of the page to be loaded.

    if( document.readyState == "complete" )

    {

    // stuff to process the event goes in here!

    }

    That way, nothing will happen until the page has finished loading.
    ×

    Success!

    Help @Alex spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.15,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...