문제

I'm writing a Firefox extension and need to notify an iFrame page of certain events. The iFrame page is contained within a sidebar created by the extension, and this iFrame page is controlled by me.

When I load the iFrame page, the extension code needs to send a notification and trigger something to happen within the iFrame page.

To accomplish this, I'm creating an event from the extension Javascript and firing the event, which the iFrame page is listening to.

Unfortunately, when invoking document.createEvent(), this error pops up (copied, with the quotes, straight out of Firebug):

Operation is not supported" code: "9

Any clues on the error, or suggestions on how to trigger something in an iFrame page from the extension Javascript?

도움이 되었습니까?

해결책

Firebug helps debug web pages. From your description it appears that the problem happens in your extension, so set up the profile according to the documentation and look in the Error Console.

Other than that, remote debugging requires seeing more of your code :)

다른 팁

That error is NS_ERROR_DOM_NOT_SUPPORTED_ERR. Are you using the right document (the content one, not the XUL window)? Although, I'm not convinced that that would error out either (in fact, I think it should work).

This is an example of code that works for me:

var eventName = "my-event";
var event = document.createEvent('Events');
event.initEvent(eventName, true, true);
document.getElementById('my_event_listener').dispatchEvent(event)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top