Frames, controling a frame problems

225 views
Skip to first unread message

Buterrip

unread,
Jun 16, 2010, 5:04:02 PM6/16/10
to Chromium-extensions
Well, i have the manifest.json correctly, injecting the code and it
works, but when i try to control a frame, by:
window.frames[2] or document.getElementsByName("main")
[0].contentWindow or parent.main, i can't...
Thanks

Daniel Wagner-Hall

unread,
Jun 17, 2010, 5:08:56 PM6/17/10
to Buterrip, Chromium-extensions
See http://crbug.com/20773

> --
> You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
> To post to this group, send email to chromium-...@chromium.org.
> To unsubscribe from this group, send email to chromium-extens...@chromium.org.
> For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.
>
>

Gildas

unread,
Jun 18, 2010, 6:16:30 AM6/18/10
to Chromium-extensions
Hi,

If you really want to be able to control a frame by its index or ID or
its reference, you can use the window.postMessage as I described
here :
http://groups.google.com/a/chromium.org/group/chromium-extensions/browse_thread/thread/218114545357d6d5#

PS : I do not know if it is a hack or not...

On 17 juin, 23:08, Daniel Wagner-Hall <dawag...@gmail.com> wrote:
> Seehttp://crbug.com/20773
>
> On 16 June 2010 22:04, Buterrip <joaocassi...@gmail.com> wrote:
>
>
>
> > Well, i have the manifest.json correctly, injecting the code and it
> > works, but when i try to control a frame, by:
> > window.frames[2] or document.getElementsByName("main")
> > [0].contentWindow or parent.main, i can't...
> > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to chromium-extensions+unsubscr...@chromium.org.

Buterrip

unread,
Jun 26, 2010, 12:31:36 PM6/26/10
to Chromium-extensions
Well Gildas, but i ask you, we are able to control a document only by
injecting script, why we don't are able to control a frame by getting
the frame without comunication between them? I think i will be not
able to comunicate with the frame too. It's a bug?
Thanks

On 18 jun, 11:16, Gildas <gildas.lorm...@gmail.com> wrote:
> Hi,
>
> If you really want to be able to control a frame by its index or ID or
> its reference, you can use the window.postMessage as I described
> here :http://groups.google.com/a/chromium.org/group/chromium-extensions/bro...

Gildas

unread,
Jun 26, 2010, 2:44:29 PM6/26/10
to Chromium-extensions
On 26 juin, 18:31, Buterrip <joaocassi...@gmail.com> wrote:
> Well Gildas, but i ask you, we are able to control a document only by
> injecting script,
Not really, content scripts can directly modify the DOM (but not
frames or parent).

> why we don't are able to control a frame by getting
> the frame without communication between them?
Because it's a bug (see Daniel link). A content script can't directly
communicate with its frames or parent. But, you can use background
page as a "proxy" to allow this kind of communication. In this case,
the background page can only rely on content script location.href to
establish the communication between content scripts. So, you cannot
send a message to a frame given its ID, index, name ... It will not
work for redirected frame content neither.

> I think i will be not
> able to comunicate with the frame too. It's a bug?
Injecting a script using "window.postMessage" as illustrated in my
example is a workaround for the bug described above. Thus it's
possible to communicate with a frame (or parent) given its ID, index,
name... In this case, the background page is not involved.

In all cases, you must set all_frames:true in manifest.json (or
allFrames:true in "details" argument of chrome.tabs.executeScript
function).

Buterrip

unread,
Jun 27, 2010, 12:28:34 AM6/27/10
to Chromium-extensions
Right, thanks :)

On 26 jun, 19:44, Gildas <gildas.lorm...@gmail.com> wrote:
> On 26 juin, 18:31, Buterrip <joaocassi...@gmail.com> wrote:> Well Gildas, but i ask you, we are able to control a document only by
> > injecting script,
>
> Not really, content scripts can directly modify the DOM (but notframesor parent).
>
> > why we don't are able to control a frame by getting
> > the frame without communication between them?
>
> Because it's a bug (see Daniel link). A content script can't directly
> communicate with itsframesor parent. But, you can use background

Buterrip

unread,
Jul 1, 2010, 1:09:38 AM7/1/10
to Chromium-extensions
Hi again, i got the problems doing the trick,
location.href='javascript:alert(top.frames[0].document.body.innerHTML)'
it's very dificult to control a frame by this way, don't you know
another way, like define the body of the frame by this location.href?

Thanks

On 26 jun, 19:44, Gildas <gildas.lorm...@gmail.com> wrote:
> On 26 juin, 18:31, Buterrip <joaocassi...@gmail.com> wrote:> Well Gildas, but i ask you, we are able to control a document only by
> > injecting script,
>
> Not really, content scripts can directly modify the DOM (but notframesor parent).
>
> > why we don't are able to control a frame by getting
> > the frame without communication between them?
>
> Because it's a bug (see Daniel link). A content script can't directly
> communicate with itsframesor parent. But, you can use background

Antony Sargent

unread,
Jul 1, 2010, 1:42:56 PM7/1/10
to Buterrip, Chromium-extensions
One workaround you might try is injecting your own script into all frames (see the 'all_frames' parameter in the docs), and then use the messaging API to have the outer frame request that your script in the inner frame take some action. 


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.

Buterrip

unread,
Jul 3, 2010, 12:45:27 AM7/3/10
to Chromium-extensions
I really still having troubles, if someone can show me an example...
Thanks

On 1 jul, 18:42, Antony Sargent <asarg...@chromium.org> wrote:
> One workaround you might try is injecting your own script into all frames
> (see the 'all_frames' parameter in the
> docs<http://code.google.com/chrome/extensions/content_scripts.html>),
> and then use the
> messaging<http://code.google.com/chrome/extensions/messaging.html> API
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > .
Reply all
Reply to author
Forward
0 new messages