views:

16

answers:

1

I have an extension that helps in submitting forms automatically for a process at work. We are running into a problem with dual select boxes where one option is selected and then that selection changes another field's options. Since setting an option selected property to true doesn't trigger the field's onchange event I am trying to do so through code.

The problem I've run into is that if I try to access or run functions on the field object from the extension, I get the error

Error: uncaught exception: [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: chrome://webformsidebar/content/webformsidebar.js :: WebFormSidebar_FillProcess :: line 499" data: no]

the line causing the error is...

if (typeof thisField.onchange === 'function')

The line right before it works just fine...

thisField.options[t].selected=true;

...so I'm not sure why this is resulting in such an error.

What surprises me most I guess is that checking for the existence of the function leads to an error.

It feels like the problem is related to the code running in the context of the extension instead of the browser window document. If so, is there any way to call a function in the browser window context instead? Do I need to actually inject code into the page somehow? Any other ideas? Thanks