Displaying external site into iframe
I'm developing site which provides allow to display external sites into iframe with extra information, similar to google images.
In most cases this works well, but some sites uses开发者_开发技巧 javascripts calls which access to parent frame, that causes "Unsafe JavaScript attempt to access frame with URL" and other errors and these sites doesn't displayed correctly.
Are there any way to fix it at least for some sites? Some kind of sandboxing? Or allowing child frame to access parent? Replace window.top somehow?
You will probably have to make proxy.
<?php
$content = file_get_contents("http://addr.to/your/content.html");
$content = preg_replace("~window\.top.*?~i", "", $content);
echo $content;
but it will be VERY unstable this way!
精彩评论