html框架集与谷歌结果“同源”错误


html frameset with google results "SAMEORIGIN" error

试图使用ajax来定位div,但它不起作用。所以现在我尝试使用框架集,例如

<frameset border=0 rows="300, *">
    <frame src="search.html" name="top" target="bottom">
    <frame src="bottom.php"  name="bottom">
</frameset>

搜索.html有一个表单、输入和提交按钮。我想在底部看到谷歌的结果。

底部.php在下面重定向。

<?php  
   header( 'Location: http://www.google.com/scholar' ) ;
?>

Nytimes.com,bing.com 和其他人都很好。但只有 google.com 有"同源"错误。

拥有它的最佳解决方案是什么?

提前谢谢。

如您所确定的,Google 通过发送x-frame-options:SAMEORIGIN响应标头来防止框架。因此,除了来自同一域(google.com)的页面外,Google页面无法装裱。

X-Frame-Options响应标头是一项安全功能,在现代浏览器中无法绕过。

参考

  • MDN - X-Frame-Options响应标头
  • 谷歌产品论坛 (2011) - Google.com 是否突然阻止了 IFraming?

如果您想在您的网站中实现谷歌搜索,请查看谷歌自定义搜索。