javascript - Changing parent window's URL from IFrame -


I have a situation where I have web apps on two different servers, where app 1 would have an app 2 in IFrame is. Any link in app 2 can be the target = "_ parent" attribute, which allows those links to open in the top window. However, I can not find any way to get the same behavior in javascript. I found that the child can call Javascript on the original frame using the parent frame parent.foo () , but it does not work in IE8 or FF3. 5. I found out how this security model works. But it sounds weird that I can not do this in javascript that I have a simple & lt; A & gt; What can I do with the tag? Strong> Is there any way to do this? I know, but (as far as I know) it only works in Firefox


Example

Server 1 / test.html

  & lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" & gt; Function myCallback (foo) {warning (foo); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Iframe src = "http: //server2/test2.htm" width = "400" height = "150" & gt; & Lt; / Iframe & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

server2 / trial 2.html

   

server1 / test.html
  & Lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" & gt; If (navigator.appName == "Microsoft Internet Explorer" window) .tat event ("Onmase", received message); And window.addEventListener ("message", received message, incorrect); Function receiveMessage (e) {if (e.origin == "http: // server2") // is important for security if (e.data.indexOf ('redirect:') == 0) document.location = e .data .substr (9); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Iframe src = "http: //server2/test2.htm" width = "400" height = "150" & gt; & Lt; / Iframe & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

server2 / trial 2.htm

   

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -