Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Iframe Cross domain communication - resize event - cross browser?

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

like image 319
Royi Namir Avatar asked Nov 02 '22 13:11

Royi Namir


1 Answers

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/

like image 110
btm1 Avatar answered Nov 09 '22 11:11

btm1