views:

49

answers:

2

I'm writing an extension which needs to manipulate the dom, including iframes, however I would like to do something a little different in case I'm in an iFrame.

How can the script detect if it is in the main page, or an iFrame?

Thanks

+1  A: 

I am not sure if that is exactly our issue, but there are known bugs with the Chrome frame handling. Most annoying is this one: http://code.google.com/p/chromium/issues/detail?id=20773

SamMeiers
I use execureScript with allFrames set to true, so I am able to run in the frames, so I was just wondering if I could tell if I'm in the main page or a frame?
DanJ
+1  A: 

Yeah, this is actually the same test you'd use in a standard web page:

if (window != window.top) {
  alert('In an IFRAME: ' + window.location.href);
}
Arne Roomann-Kurrik