How to Stop Gmail from maximizing an iFrame?

2019-07-19 09:23发布

问题:

I am trying to create a webpage with Gmail embedded in an iframe. However, Gmail has some javascript code that executes whenever it is loaded. I believe the following js code snippet is what causes Gmail to hijack the window and maximize itself, destroying my parent iframe:

if (top.location != self.location) {
  top.location = self.location.href;
}

Preferably, I am looking for a solution that works cross-browser (and does not involve greasemonkey, or some other browser-based hack). If jquery has some applicable function/plugin, that would be great.

回答1:

As the code Gmail uses is located in a block it's hard to prevent it from running. There might be some useful insights in an article about preventing frame-busting.



回答2:

There is an SO question by Jeff Atwood that addresses this (but kind of in reverse): Frame Buster Buster ... buster code needed