显示嵌入Google文档的文档的完整长度 [英] Display full length of document for embed google document
本文介绍了显示嵌入Google文档的文档的完整长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在iframe上不显示滚动条的情况下显示嵌入式google文档的完整长度?
How can I display the full length of an embedded google document without the scroll bar on the iframe?
<html>
<style>
body { margin: 0; padding: 0; o}
iframe { margin-left: 2vw; margin-top: 2vh; height: 100%; width: 90vw; }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<body>
<iframe srcdoc="" frameborder="0" scrolling="no" height="100%"></iframe>
<script>
$(function() {
$.get("https://docs.google.com/document/d/17OkIgtNdV1flno_783tJm2xWU0NBh7uEmZ5wEXP2E9g/pub?embedded=true", function(html) {
var contents = $("iframe").contents();
contents.find("html").html(html);
setTimeout(function() {
contents.find('a[href^="http://"]').attr("target", "_blank");
contents.find('a[href^="https://"]').attr("target", "_blank");
}, 1000); // Actually not sure if timeout is required here...
});
});
</script>
</body>
</html>
显示屏可能显示一页和一半文字,然后停止.
The display shows maybe a page and half of text and stops.
推荐答案
Google文档目前很高兴通过CORS请求提供已发布的文档.
Google docs is currently happy to serve published documents via CORS requests.
这意味着您不需要iframe
即可嵌入文档.您可以改为使用XMLHttpRequest
来GET
您的文档,并将响应放入div
的innerHtml
中.
This means that you don't need an iframe
to embed your documents. You can instead use an XMLHttpRequest
to GET
your document and put the response inside a div
's innerHtml
.
这篇关于显示嵌入Google文档的文档的完整长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文