首先,你需要做的添加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>
嗨,你需要與嵌入式=真 – 2017-10-09 19:15:58