2

I'm using the jQuery plugin: http://plugins.jquery.it/project/jquery-iframe-resizer

OK for resize between 2 different domains. My enablePublicMethods option is to true.

But i need to get the ID frame in my page contained. I the plugin example, it's ok but by a click:

<a href='#' onclick="if ('parentIFrame' in window) window.parentIFrame.close();return false;">Close</a>

Test on the 'parentIFrame' in window working just on the onclick event. When i try to get on the load, the parentIFrame is unknown:

$( window ).load(function() {
  if ('parentIFrame' in window){ 
       console.log("OK"); 
       console.log(parentIFrame.getId();
  }
});

How get the parentIFrame objet without click ??

4

1 回答 1

1

您需要等到 iFrame 第一次调整大小,然后该方法才可用。

在页面加载期间,您需要轮询以查看 parentIFrame 是否存在,一旦设置完成,您就可以调用 getID();

于 2015-03-10T19:51:07.310 回答