开发者

How to access and run field events from extension js?

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 onchan开发者_Go百科ge 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?


The only way we found this could be done is by injecting code into the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜