php生成的页面不';在iframe中不显示Google文档内容,在html中显示相同的文本

php生成的页面不';在iframe中不显示Google文档内容,在html中显示相同的文本,php,html,iframe,google-docs,Php,Html,Iframe,Google Docs,我的页面分为4个部分,每个部分由php对象的方法生成。 第一部分只显示一个文本,效果很好,第二部分和第四部分都没有(到目前为止) 我的问题是第三部分应该显示嵌入式谷歌电子表格。 php页面创建了正确的html代码,事实上标题文本显示正确,但iframe显示了来自Google的消息,表示请求的文件不存在 然后我按Ctrl+U打开页面源代码(我使用的是Firefox),复制文本,粘贴到新的test.html,保存到服务器,在Firefox中打开新的test.html,现在Google喜欢它,ifra

我的页面分为4个部分,每个部分由php对象的方法生成。
第一部分只显示一个文本,效果很好,第二部分和第四部分都没有(到目前为止)

我的问题是第三部分应该显示嵌入式谷歌电子表格。
php页面创建了正确的html代码,事实上标题文本显示正确,但iframe显示了来自Google的消息,表示请求的文件不存在

然后我按Ctrl+U打开页面源代码(我使用的是Firefox),复制文本,粘贴到新的test.html,保存到服务器,在Firefox中打开新的test.html,现在Google喜欢它,iframe正确显示

为什么我有两个来源相同的页面,但一个有效,另一个无效

以下是该页面的完整php代码:

<?php
  $filename = "parameters-test.txt";
  $file_size = filesize($filename);
  $handle = fopen($filename, "r");
  $content = fread($handle, $file_size);
  fclose($handle);

  $content = str_replace('\"', '"', $content); // ??? why do I need this? And do I need only this? Isn't there some decode function?
  $alldata = json_decode($content);
  $pages = $alldata->page;
  $parameters = $alldata->parameters[0];

  $websiteTitle = $parameters->websiteTitle;

  $sheets = array();

  foreach($pages as $page) {
    $sheet = new Sheet();
    $sheet->load($page);
    array_push($sheets, $sheet);
  }

  if(isset($_GET["pageId"])) $currentSheet = $_GET["pageId"];
  else $currentSheet = 0; // this is the Welcome page

  class Sheet {
    public $definition = '';

    public function load($parameters) {
      $this->definition = $parameters;
    }

    public function showTitle() {
      echo '<h1>';
      echo $this->definition->title;
      echo '</h1>';
      echo "\n";
    }

    public function showHeader() {
      if($this->definition->heightHeader) {
        echo '<iframe width="';
        echo $this->definition->width;
        echo '" height="';
        echo $this->definition->heightHeader;
        echo '" frameborder="0" src="https://docs.google.com/spreadsheet/pub?key=';
        echo $this->definition->documentId;
        echo '&single=true&gid=';
        echo $this->definition->headerSheetId;
        echo '&output=html&widget=false&gridlines=false&range=';
        echo str_replace(':', '%3AD', $this->definition->rangeHeader);
        echo '"></iframe><br />';
        echo "\n";
      }
    }

    public function showBody() {
      echo '<iframe width="';
      echo $this->definition->width;
      echo '" height="';
      echo $this->definition->heightBody;
      echo '" frameborder="0" src="https://docs.google.com/spreadsheet/pub?key=';
      echo $this->definition->documentId;
      echo '&single=true&gid=';
      echo $this->definition->bodySheetId;
      echo '&output=html&widget=false&gridlines=false&range=';
      echo str_replace(':', '%3AD', $this->definition->rangeBody);
      echo '"></iframe><br />';
      echo "\n";
    }

    public function showLinks() {
    }
  }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="favicon.ico" rel="icon" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="index.css" />
    <title><?php echo $websiteTitle; ?></title>
  </head>
  <body>
    <?php
      $sheets[$currentSheet]->showTitle();
      $sheets[$currentSheet]->showHeader();
      $sheets[$currentSheet]->showBody();
      $sheets[$currentSheet]->showLinks();
    ?>
  </body>
</html>

这是测试的现场吗?我无法复制它——如果我将你的html的精确副本上传到我的Web服务器,它就会工作,如果我上传一个简化的php版本,它也会工作。我关闭并重新打开了Firefox,现在它可以工作了。这是我的第一个php页面,我没有测试正在构建的页面的经验。这是某种缓存损坏吗?很难说,因为我从来没有看到过这个问题。很高兴它现在对你有用!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="favicon.ico" rel="icon" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="index.css" />
    <title>this is the title</title>
  </head>
  <body>
    <h1>Hotshots pool league</h1>
<iframe width="500" height="300" frameborder="0" src="https://docs.google.com/spreadsheet/pub?key=0AqEyi7du69LQdHRJXzViMlhEdHVYY2E4X1hnZ21EQ2c&single=true&gid=12&output=html&widget=false&gridlines=false&range=A1%3ADZ999"></iframe><br />
  </body>
</html>