Why can't iframe set parent location.hash?

I have a window containing an iframe containing an iframe, for example:

+---------------+
|      Top      |
| +-----------+ |
| |   Middle  | |
| | +-------+ | |
| | | Inner | | |
| | +-------+ | |
| +-----------+ |
+---------------+

Top and Middle are in the same domain, but Inner is in the other domain. I need Inner to chat with Top. The only way I know to do this, which is supported in IE7 (which I need to support), is to change the hash of the window layout. However, I do not want the information to appear in the location bar, so I introduced an average iframe.

I want Inner to change the middle hash. The average will read the hash and tell Top with whom it has permission to speak directly.

However , in Firefox 3, I was unable to write a middle hash from Inner. An error does not occur, but the hash does not change. Writing to it location.hrefcauses a permission error.

Top , Middle , Top , Inner Middle , , , , ! ( .)

. . Inner , . Middle , .

Inner ?


. , - . , . - ( ) - . , . HTML 5 postMessage().

: http://softwareas.com/cross-domain-communication-with-iframes

+5
6

iframe 'src' ( jquery), :

$("#iframeWindow").attr('src', "http://<CHILD URL>/#hello");

iframe href ( ), :

window.top.location.href = "http://<PARENT URL>/#hello"

/ ,

var last = "";
setInterval(function() {
    if(last == window.location.href) return;
    last = window.location.href;

    //do stuff with 'window.location.hash'
}, 1000);

, ,

window.top.location.href = window.top.location.href + "#hello"

(href hash)

3 11, , .. 6/7/9, firefox 3.6/4

edit1: ,

edit2: http://dl.dropboxusercontent.com/u/14376395/html/xdomain.html:)

edit3: : , , iframe'd, , -

edit4: http://ternarylabs.com/2011/03/27/secure-cross-domain-iframe-communication/, API JavaScript JavaScript

edit5: Dropbox 'dl.dropboxusercontent.com'

+6

location.hash, . .

+1

, Firefox, Bugzilla, EricLaw.

+1

, ? (, , , ). , - google . .

0

, , postMessage? FF3, FF3 - , postMessage, bingo: -)

xssinterface. , , .

0

, . , Inner . , .

-1

All Articles