1

Page A and page B are on different domains.

A is iframed on page B.

I need to call a function which is on page B from page A.

Is this possible without something like porthole?

Basically what I'm trying to do is a simple push notification (A notifies B), don't need to transfer any content.

Chad
  • 2,365
  • 6
  • 26
  • 37

3 Answers3

1

There is an HTML5 way to do this with cross window messaging.

There are various work-arounds when HTML5 isn't available that can be used even between different origins.

jfriend00
  • 683,504
  • 96
  • 985
  • 979
0

If you want to avoid using that specific library you could use the concept it's based off of and roll your own. Here's a pretty in depth article that describes the technique without the use of a library: http://softwareas.com/cross-domain-communication-with-iframes.

Landon
  • 561
  • 1
  • 3
  • 10
0

Put A and B with the same domain, different subdomain is fine. Then in the iframe A, you can call parent.function_name (parameter1, parameter 2). If you need to call that function very often, you may want to do this :

function p(data, div_id){parent.p(data, div_id);}  

then in iframe A, you can just call p(data, div_id), which will actually call page B's function. I have used this a lot of comet streaming. If you are interested, you may read this, which basically use iframe to communicate with data:

http://www.shanison.com/2010/05/10/stop-the-browser-“throbber-of-doom”-while-loading-comet-forever-iframe/

Shanison
  • 2,295
  • 19
  • 26