0

I am having lots of issues on a website because my jQuery is causing errors due to the fact that it is being rendered inside of an iFrame. Is there any way I can tell my jQuery not to load when it is inside of an iFrame?

bcloutier
  • 411
  • 2
  • 4
  • 11
  • 3
    Seems like dupe of http://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t – JoeyJ Jun 22 '12 at 20:22

3 Answers3

1

This should work:

window.opener != null
jcubic
  • 61,973
  • 54
  • 229
  • 402
1

As Greg said in the link in the comment on the question, you can use 'if(top===self){ outside iframe code here } else { inside iframe code here}' to do this.

Jasper Mogg
  • 924
  • 2
  • 8
  • 23
1

from @Greg answer

if (top === self) { not in a frame } else { in a frame }

top and self are both window objects (along with parent), so you're seeing if your window is the top window.

Greg answer

Community
  • 1
  • 1
shareef
  • 9,255
  • 13
  • 58
  • 89