Wednesday, January 11, 2012

Send custom message from iframe guest to iframe host where host HTML from portlet


I'm trying to send a custom message from an iframe guest to an iframe host using jQuery (We are developing both guest and host). The guest and host are on the same domain but on different ports. Also, the iframe host is being rendered from a portlet within a Liferay portal instance (5.2.3) and the portal mangles the host URL of the portlet. The host and guest URLs look like:



host: http://localhost:8080/host/foo/bar?p_p_id=portletname_WAR_portletname_INSTANCE_nNz9&...



guest: http://localhost:8081/guest



I know that trying to do this messaging violates the same origin policy enforced by browsers. To get around this I've looked at using PortHole, EasyXDM and the jquery-postmessage-plugin.



The problem I have is this: For these libraries to work the sender (iframe guest) needs to know the host url but cannot know the mangled portlet host url in advance.

No comments:

Post a Comment