[SOLVED] Annoying Illogical Javascript Error

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

[SOLVED] Annoying Illogical Javascript Error

Post by Stryks »

I dont know what I am doing to be getting this. I have read somewhere that it may be an bug in firefox (which is what I am using by the way), but I am not sure. Based on how illogical the error is it may well be true.

Anyhow, I have a javascript call in the onLoad event of my <body> tag. Just a simple setfocus. If I add a second command after it, even a simple alert, it throws back the following error.

Error: [Exception... "'Permission denied to get property XULElement.selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame :: <unknown filename> :: onload :: line 0" data: no]

It has me stumped. Any ideas why this would be so?
Last edited by Stryks on Sun Jan 02, 2005 1:41 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I think I had this "problem" a while ago.. I think I solved it by calling a start-up function I created with all the junk I originally had in the event. In the end, it's cleaner that way too. :)
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post by Stryks »

Thanks for the reply feyd.

I seem to have it working without any errors now but I really dont know why.

Basically I just switched the calls around, so instead of having:

Code: Select all

onLoad="document.postcode_add.form_postcode.focus(); alert("hi");"
I now have:

Code: Select all

onLoad="alert("hi"); document.postcode_add.form_postcode.focus();"
and it all works without the error.

Of course, the purpose wasnt really to have the alert in there, so I replaced it with my function and it all works the way it was supposed to (the original problem was happening for my function so I simplified the call until I wound up calling alert to test it).

Go figure. 8)
Post Reply