Php 将HTML框架src设置为google.com;不起作用
我有以下php代码:Php 将HTML框架src设置为google.com;不起作用,php,html,google-chrome,Php,Html,Google Chrome,我有以下php代码: <?php require_once("support.php"); $query = $_POST["search"]; $google = "http://www.google.com/search?q=" . $query; $bing = "http://www.bing.com/search?q=" . $query; $yahoo ="http://search.yahoo.com/search?p=" . $query; $ask = "http:/
<?php
require_once("support.php");
$query = $_POST["search"];
$google = "http://www.google.com/search?q=" . $query;
$bing = "http://www.bing.com/search?q=" . $query;
$yahoo ="http://search.yahoo.com/search?p=" . $query;
$ask = "http://www.ask.com/web?q=" . $query;
$body= "<html><head>";
$body .= "<script src=\"scripts.js\"></script>";
$body .= "</head>";
$body .= "<frameset rows=\"50%,50%\" cols=\"50%,50%\" >";
$body .= "<frame src=\"$google\" />";
$body .= "<frame src=\"$bing\" />";
$body .= "<frame src=\"$yahoo\" />";
$body .= "<frame src=\"$ask\" />";
$body .= "</frameset>";
$body .= "</html>";
echo $body;
?>
它将生成以下html:
<html>
<head>
<script src="scripts.js"></script>
</head>
<frameset rows="50%,50%" cols="50%,50%" >
<frame src="http://www.google.com/search?q=adf" />
<frame src="http://www.bing.com/search?q=adf" />
<frame src="http://search.yahoo.com/search?p=adf" />
<frame src="http://www.ask.com/web?q=adf" />
</frameset>
</html>
当我在google chrome中打开它时,我从上面的url中得到了4个包含预期内容的框架。但在第一帧中,谁的src来自谷歌,我什么也得不到;只是一个空白的框架。
知道这是怎么回事吗
谢谢您可以使用开发者工具作为chrome的扩展。Firebug也会做类似的工作。点击网页上的Ctrl+Shift+J,chrome将弹出开发者工具界面 从这里,单击Console,并检查是否有任何错误消息。我记得在使用同一原点x帧选项时遇到了类似的问题——但这是针对GDocs的,其中存在身份验证问题。在我的案例中没有简单的解决方法,我使用了一个单独的选项卡 此线程还可能有助于:
谷歌将其标题设置为
SAMEORIGIN
,这禁止非谷歌网站嵌入其页面。大多数现代浏览器都尊重此设置。您可以让服务器下载谷歌搜索结果页面,并使用curl将其提供给您的框架
<?php
function getHtml($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$google = getHtml("https://encrypted.google.com/search?q=".$query) or die("dead!");
#....
?>
Google不喜欢他们的内容被嵌入另一个页面?