Prevent Iframe From Changing Parent Location
Suppose http://a.com/foo contains
Solution 1:
Parent can use sandbox
attribute on iframe
:
http://www.w3schools.com/TAgs/att_iframe_sandbox.asp
Then iframe
will no longer be able to redirect parent.
Solution 2:
What may be happening is a link inside b.com has the attribute Target='_parent'. This would make the window/iframe parent update.
If you control b.com - ensure all your targets are _self.
Solution 3:
that's called 'frame busting'. Supposedly there are techniques to stop that ( http://seclab.stanford.edu/websec/framebusting/index.php ).
Maybe instead of an iframe you could use ajax or similar to load the frame's content into your page?
Solution 4:
An ajax solution could work if I create a.com/proxy.php
which will use cURL to fetch b.com.
Pros:
- can change or remove any script
- can adjust b.com content (preview mode)
- can get around cross-domain iframe restrictions
Cons:
- cookies/sessions on b.com won't be available
- b.com may require scripts to create its content
- burden of bandwidth
- coding effort to make hrefs work
Post a Comment for "Prevent Iframe From Changing Parent Location"