-
30 Aug 2008 7:19 AM #1
prevent iframe redirect
prevent iframe redirect
Hi,
I have a website inside an iframe.
Both the website and the iframe are at the same domain but I'm not allow to modify the website code. I have full control over the top frame code.
When the inner page is inside an iframe it uses a code to load the page without the iframe:
Is there a way to prevent this without modifying the inner page code?Code:if (top != self) { top.location.replace('http://example.com'); }
Can I somehow overwrite the top.location.replace function?
I've tried:
and I also tried:Code:top.location.replace = new Function("x", "return false");
Both doesn't work.Code:top.location.replace = function(nUrl) { return false; }
Thanks
-
30 Aug 2008 7:32 AM #2
Tried setting
after its loaded?Code:frame.window.top = frame.window.self;
"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
30 Aug 2008 11:08 AM #3
Should I put it in the top frame or in the inner iframe?Tried setting frame.window.top = frame.window.self;
after its loaded?
I don't have access to the inner iframe code only the top frame.
Is it possible to overwrite internal javascript function like location.replace()?
-
30 Aug 2008 11:27 AM #4
@dolittle -- If:
1) you are using ManagedIframePanel
2) the "if (top != self) { top.location.replace('http://example.com'); }" is executed during/after onload event.
you could try:
Code:new Ext.ux.ManagedIframePanel({ defaultSrc : 'yourLocalPage.html', listeners: { domready : function(frame){ var w; if(w = frame.getWindow()){ w.top = w.self; } } },.... });That, is likely NOT allowed.Is it possible to overwrite internal javascript function like location.replace()?"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
30 Aug 2008 11:43 AM #5
Unfournatly I can't use ManagedIframePanel because of its GPL license and because the code has to be small.
Thanks anyway.
-
30 Aug 2008 11:45 AM #6"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
30 Aug 2008 2:39 PM #7
I've created a simple test.
I put the following code in the header of the inner iframe and it works on in FF and not in IE7:
IE7 bug says:Code:window.top = window.self;
I tried to create the iframe using your code with ManagedIframePanel and the domready event:Code:Error: Not implemented Code: 0
In the iframe.html body I put:Code:Ext.onReady(function(){ new Ext.ux.ManagedIframePanel({ renderTo: 'iframeWrap', defaultSrc : 'iframe.html', listeners: { domready : function(frame){ var w; if(w = frame.getWindow()){ w.top = w.self; } } } }); });
But it still redirects.Code:if (top != self) { top.location.replace('http://localhost/test/iframe.html'); }
Another issue is that all the pages of the website have the redirect code but I'll be able to attach the event only to the first page.
-
30 Aug 2008 3:34 PM #8
@dolittle -- I'd say you have too many constraints imposed upon you (and from your own domain, boo) .
Where/when in the embedded page(s) are they asserting top != self?"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
30 Aug 2008 4:26 PM #9
It turns out that I can inject javascript code before the frame breaker but can't take it out.
Can I change the innerHtml of the script using another script that is being executed before?
The script with the top!=self is placed at the bottom of the body part of the iframe:
I know it sound strange but I need to put a CMS inside an iframe, both on the same server but I'm not allowed to change the code of the CMS.Code:<body> some html ... ... <script type="text/javascript"> if (top != self) { top.location.replace('http://best999.ning.com'); } </script> </body>
-
3 Sep 2008 5:56 AM #10
@cwhsjb
I don't understand what you are saying.


Reply With Quote



