I have a content script set for a very specific URL. I placed an
iframe the background page. The content script doesn't load. Is this a
bug?
The content script loads fine when I open the specific URL in a new
tab. I even tried changing the specific URL to http://*.
google.com and
I get the same behavior.
Bottom line, content scripts aren't loaded into iframes if the iframe
is within the background page. Why?
On Jun 5, 1:25 am, Sam <
sam.lb.hol...@gmail.com> wrote:
> Okay, thanks PhistucK, I didn't know that.
>
> Now the only issue left for me to solve is how do I get my content
> script to load in an iframe if the iframe is in the background page?
>
> On Jun 5, 1:22 am, PhistucK <
phist...@gmail.com> wrote:
>
>
>
> > Just for you information, this error message is caused by Flash. Whenever it
> > is loaded in an iFrame, it tries to go to the location.href of the parent
> > document or something, automatically, so it triggers this error message. You
> > should not worry about it.
>
> > ☆PhistucK
>
> > On Sat, Jun 5, 2010 at 01:09,Sam<
sam.lb.hol...@gmail.com> wrote:
> > > Okay, I've figured out how the long-lived connections work. It all
> > > works when I have a tab open to the URL with the specific content
> > > script. But, when in the background page, I put an iframe with the URL
> > > and I get this error message:
>
> > > Unsafe JavaScript attempt to access frame with URL chrome-extension://
> > > dcjnlapaoiolconmenhlbbbcaheehhbk/background.html from frame with URL
> > > http://******.***********.com/********.swf. Domains, protocols and
> > > ports must match.
>
> > > (I hid the iframe's src URL for privacy purposes.) So why would I be
> > > getting this message when I put an iframe in my background page, but
> > > not when I just open a tab to the URL? As you can see the URL is
> > > pointing to a swf file, so there is no javascript that would be trying
> > > to access the topmost window (the background page), unless a swf file
> > > can do that. But even if it was trying to access window.top, why would
> > > that prevent the content script from running and connecting to the
> > > background page?
>
> > > I might also point out that I get this error message even when I empty
> > > the content script file. Therefore, the content script isn't causing
> > > this error.
>
> > > On Jun 4, 1:18 pm,Sam<
sam.lb.hol...@gmail.com> wrote:
> > > > Yea, this is what I figured too. So how do I do this? Should I write
> > > > chrome.extensions.connect() in my content script? How does the connect
> > > > method work? The documentation on the method is hard for me to
> > > > understand and I can't find any examples.
>
> > > > On Jun 3, 7:59 pm, Daniel Wagner-Hall <
dawag...@gmail.com> wrote:
>
> > > > > It will have the same tab details as the page containing the iframe.
> > > > > Your best bet is to have the content script connect to the background
> > > > > page using a port connection, rather than a sendRequest, and keep
> > > > > track of what content scripts have loaded.
>