编辑嵌入谷歌文档

问题描述:

我创建一个网站,在我的学校导师的人,我需要嵌入一个谷歌的文档,这样任何人谁访问的页面可以编辑他们与谷歌帐户的OFC登录后。我现在拥有它的方式不可编辑,但它嵌入了。有谁知道如何做到这一点,甚至可以做到这一点? 这是我到目前为止。编辑嵌入谷歌文档

<iframe src="GOOGLE-DOC-URL" height = "1000" width = "1000"></iframe>

我所做的网页公开发布了它,我已经做了很多的期待就这个问题和发现添加“无缝”,以用来工作的iframe语句,但现在显然被弃用,我试过了,它不起作用。谢谢。

+0

嗨,你需要与嵌入式=真 – 2017-10-09 19:15:58

首先,你需要做的添加URL谷歌文档与此PARAMS:

https://docs.google.com/document/d/KEY/pub?embedded=true

其次,我做一个AJAX调用来获取信息,并从谷歌文档API的响应:

https://codepen.io/headmax/pen/dVeMmE

要创建自己的页面:在AP我的文档打印HR html元素

html页面后:

<html> 
<body> 
<h1>The text below is pulled live from Google Docs</h1> 
<h4>If there is an update to the doc and you refresh the page, it should update.</h4> 
<hr> 
<script> 
function get_information(link, callback) { 
    var xhr = new XMLHttpRequest(); 
    xhr.open("GET", link, true); 
    xhr.onreadystatechange = function() { 
     if (xhr.readyState === 4) { 
      callback(xhr.responseText); 
     } 
    }; 
    xhr.send(null); 
}; 

//Now initilisation and call & working from the anonyme callback function with dom response : 

get_information("https://docs.google.com/document/d/1yf5plpYBYsBMCaeeDpTkapgR8jZtg4XCfiTvRG5qRWY/pub?embedded=true", function(text) { 
    var div = document.createElement("div"); 
    div.innerHTML = text; 

    // Remove css that comes with Google Doc embeds 
    // If you want the Google Doc styling, comment these out 
    div.removeChild(div.childNodes[1]); 
    div.removeChild(div.childNodes[0]); 

    document.body.appendChild(div); 
    document.body.appendChild(document.createElement("hr")); 
    } 
); 
</script> 
</body> 
</html> 
+0

我已经嵌入=真PARAM添加URL。那么这个Ajax语句在div元素中的含义是什么?我应该怎么做呢? – Addis16

+0

首先添加你的URL API中的例子来加载自己的谷歌文档,然后将文档可以通过Ajax调用这个AJAX返回读取的文档谷歌文档的输出中。只需更换网址“示例中的红色”即可。问候。 (这不是一个有效的网址:GOOGLE-DOC-URL) – 2017-10-09 22:51:16

+0

这是codepen.io的一个例子,因为没有按我的需要运行。 https://codepen.io/headmax/pen/dVeMmE – 2017-10-09 23:08:11