gpt4 book ai didi

angularjs - Google文档iframe-更改填充

转载 作者:行者123 更新时间:2023-12-04 08:21:31 24 4
gpt4 key购买 nike

我有一个嵌入的iframe,它是通过发布Google文档创建的。iframe自动对其body施加较大的填充,从而导致文本非常狭窄且难看。我必须改变这一点。

我试图创建一个自定义指令:

app.directive('iframeWithStyle', [function(){
return {
restrict: 'A',
link: function(scope, element, attrs){
element.on('load', function(){
var iframe = element[0];
var grabbedElement = iframe.querySelector("body");
// -> grabbedElement is null here
});
}
}}]);

适用于:
<iframe iframe-with-style
src="https://docs.google.com/document/d/somethingABC123/pub?embedded=true">
</iframe>

但是 iframe.querySelector在以下位置返回 nulliframe.contentWindow.document结果 as expected:

Uncaught DOMException: Blocked a frame with origin "http://localhost:8100" from accessing a cross-origin frame.



我已经看过一种解决方法,但是我感觉它是过大的(例如: safe cross-communication with messages)。

我试图通过将一些CSS应用于我可以达到的范围来对抗填充。
例如:
iframe {
padding: 0px !important;
margin-left: -50px;
margin-right: 50px;
}

应用于 bodyiframe的css似乎被忽略了。

曾经有一些便利属性,例如 marginwidth 。也尝试过。
我也想知道谷歌是否不提供一些“糖”,但是谷歌搜索没有帮助。

注意:它实际上不一定必须是 iframe,但是我需要以可读的方式在应用程序中显示格式化的gdoc;为此,我需要减少填充。

添加一个punker: https://plnkr.co/edit/XIkgPe7ecLyFfhq1Q3Sv?p=preview

最佳答案

将网址的最后一部分从true更改为false

https://docs.google.com/document/d/1s2nOQZ39dKD-hsmox5twmmKKkuXzOopT1eXFbMh5DeE/pub?embedded=false



该演示包括所有嵌入式元素的使用:
<iframe><embed><object>
Plunker

当您设置 embedded=true时,Google服务器将在 .c1内的内容的 <body>中添加一个名为 <iframe>的类。

.c1 {
background-color: rgb(255, 255, 255);
max-width: 468pt;
padding: 72pt 72pt 72pt 72pt;
}


如果您问我,那简直就是鲁Google的Google。我建议您在内容本身上设置填充,并设置 embedded=false

关于angularjs - Google文档iframe-更改填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44518769/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com