Click to See Complete Forum and Search --> : Prevent error message when dyn. menu is not loaded completely


Alex
08-19-2003, 05:59 AM
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!

AdamGundry
08-19-2003, 06:33 AM
You can use window.onerror = null to suppress error messages, if that's what you want.

Adam

Alex
08-19-2003, 06:47 AM
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

Alex
08-27-2003, 08:46 AM
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!

Khalid Ali
08-27-2003, 09:11 AM
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.

Alex
08-28-2003, 07:54 AM
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?

AdamGundry
08-28-2003, 08:02 AM
IIRC, changing the error handler to make it return false should make the browser log errors normally.

Adam

Khalid Ali
08-28-2003, 08:07 AM
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.

Alex
08-28-2003, 09:37 AM
Hi Khalid,

thanks for that hint, I will try out...

Alex
08-28-2003, 10:39 AM
Thank you yery much for your support!

wallacedm
08-28-2003, 05:48 PM
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.