views:

128

answers:

3

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?

Thanks!

A: 

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).

sdwilsh
A: 

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 :)

Nickolay
A: 

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)
shex