Iframe Cross domain communication - resize event - cross browser?

会有一股神秘感。 提交于 2019-12-10 14:04:27

问题


When the main Window wants to send message to a child Iframe -

It sets the child's Iframe url to its current url+ hash (which represents data).

But how would the iframe get's the new data ?

We have 4 options : ( i'm not talking about new api's eg postMessaage nor XDM libraries)

  • The child is polling the new hash ( setTimeout)

  • The main window can resize the iframe (the iframe must register onResize)

  • The OnHashChange Event can be used on the iframe

  • Destroying/creating proxy Iframe which uses "onload" to send msg (javascript function !) to its "SameDomainIframe" via parent.frames['samedonain'].sendData(...)

Here comes my question : (regarding option#2 ( resize event) ):

According to this article :

In Firefox, Opera, Google Chrome and Safari, the onresize event is fired only when the size of the browser window is changed. In Internet Explorer, the onresize event is fired when the size of the browser window or an element is changed.

Question :

Is there any cross browser solution for this resize thing ?

I don't want a situation where a user resize the browser , and the iframe will re-read the data !

I want the data to be read Only when I send a message to the iframe and manually resize it


回答1:


You can use porthole which is a cross browser proxy script for iframes you will need to be able to host a small proxy file on the receiving end of the other iframe though. You can then pass information and events from one iframe to another across browsers and domains

http://ternarylabs.github.io/porthole/



来源:https://stackoverflow.com/questions/19195363/iframe-cross-domain-communication-resize-event-cross-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!