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?
-
3Seems like dupe of stackoverflow.com/questions/326069/…JoeyJ– JoeyJ2012年06月22日 20:22:01 +00:00Commented Jun 22, 2012 at 20:22
3 Answers 3
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.
Comments
This should work:
window.opener != null
Comments
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.