views:

150

answers:

2

Can the iframe access its parent if i changed its src to "about:blank" after loading it in the parent page?

Note: the iframe is in another domain not the same as the parent page.

+1  A: 

Generally, no. This is known as cross-site scripting (XSS) and is considered a security risk, so most browsers prevent it.

Phil H
so how pronto website do this?Pronto Bookmarklethttp://www.pronto.com/user/getBookmarklet.doPronto Bookmarklet Video Demonstrationhttp://www.vimeo.com/1626505
Amr ElGarhy
+4  A: 

No. If you change the src attribute of the frame to about:blank the content of that frame will be replaced with the blank document, and any javascript running inside the iframe will terminate.

If you need a way for the two to communicate, one of the ways to go is to expose some kind of JSON based endpoint that can be called from one of the domains, while the other polls for a result.

UPD: Regarding your pronto question, I would guess they don't use an iframe. Pronto is a bookmarklet, which allows code to run in the "outer" page. While I didn't verify this, I'd guess they are able to make the browser page load their JS library via an injected script element, and display their UI that way.

levik
so how pronto website do this? Pronto Bookmarklet http://www.pronto.com/user/getBookmarklet.do Pronto Bookmarklet Video Demonstration http://www.vimeo.com/1626505
Amr ElGarhy