0

我正在寻找一种程序化方式来在 Google 站点上包含来自 Google Drive 的视频。我目前的计划是使用每行的嵌入 URL 播种电子表格,然后通过 Google Apps 脚本进行挖掘以嵌入内容。

但是,在这个程序的核心,我相信我遇到了一个基于与http://code.google.com/p/google-apps-script-issues/issues/detail?id=1649相似性的已知问题这是在 Google 网站上嵌入 YouTube 视频的 Google 错误。

如下面的 URL 所示,我有一个非常小的 HTML 文件,可以播放我上传到 Google Drive 的 Apple 示例 MP4 文件,以便我可以嵌入它并按预期工作:

http://www.pccc.com/downloads/junk/test/test.html

但是,如果我为 Apps 脚本复制相同的 HTML,我看到的只是灰色边框和添加的“这是一个测试”文本,以确认最新版本已发布:

function doGet(e) {
  var html = '<iframe src="https://docs.google.com/a/documentshare.com/file/d/0B7wNkTj2wH_TLTdwcWo2NW5SWnM/preview" width="640" height="385"></iframe> This is a test';
  return HtmlService.createHtmlOutput(html);
}

任何指针表示赞赏。

4

2 回答 2

1

This is doable but in a different way. You can have full access to a sites page HTML including iframes via script. See the doumentation. Do the edit first manually on the sites page: Insert > Video > Google docs. Then use the HTML generated as a template to write your own programmatically.

Edit: For example, follow these steps:

  1. Create a web page called TEST
  2. Edit the page and write "this is a test" and then Insert > Video > Google Docs Video (the url to paste is: https://docs.google.com/a/documentshare.com/file/d/0B7wNkTj2wH_TLTdwcWo2NW5SWnM/preview
  3. Save the page and run this code (authorise when prompted and rerun).
  4. Refresh your page in the browser.

The code will change the page programatically but you will still have a working video.

function myFunction() {
      //Change the domain and site to yours below
      var page = SitesApp.getSite('YOURDOMAIN', 'YOURSITE').getChildByName('TEST');
      var html = page.getHtmlContent();
      Logger.log(html);
      page.setHtmlContent(html.replace("test", "test at " + new Date()));
      var newhtml = page.getHtmlContent();
      Logger.log(newhtml);
      return;
    }
于 2012-09-14T21:44:50.730 回答
0

不幸的是 HtmlService 不支持 iframe。

于 2012-09-12T22:42:10.943 回答