The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features

See the new Forums

How to send message from background page to all injected scripts inside a tab

Forums » Dev.Opera » Opera Extensions Development Discussions

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

10. October 2011, 15:28:47

jusob

Posts: 2

How to send message from background page to all injected scripts inside a tab

Hello,
I need to send a message from the background process to all injected script inside a tab. It seems I can only send to all scripts across all tabs, or to a single script by using event.source.

I tried to send a message to all tabs that contain the top document URL as a way for each script to filter on this value. Unfortunately, injected script inside frame/iframes can not read the location.href value of the top window:

Uncaught exception: ReferenceError: Security error: attempted to read protected variable


Is there any way to do this in Opera?

Thank you

10. October 2011, 22:09:57

d4n3

Posts: 957

Perhaps you could use cross-document messaging to send the top level url to child frames?

Can you post more details about what you're trying to do exactly?

13. October 2011, 00:31:54

jusob

Posts: 2

Originally posted by d4n3:

Perhaps you could use cross-document messaging to send the top level url to child frames?

Can you post more details about what you're trying to do exactly?



I'm trying to detect all the iframes from a specific domain inside a page. These iframes could be loaded at any time, long after the page is fully loaded, and inside other frames and iframes.

I released the add-on for Safari and Chrome already. Since the script is injected in each new frame/iframe, I send the new URL along with the top window URL so that the background page can figure out how may iframe for the domain I'm looking for are loaded inside each tab.

Forums » Dev.Opera » Opera Extensions Development Discussions