javascript - 嵌入文档时不需要的页面边框
问题描述
我可以在 Chrome 的新标签中显示 pdf。但我在页面周围看到一个不需要的框架。
我使用对象标签嵌入文档,但我也使用 iframe 始终显示边框(将 frameborder 设置为 0),也使用样式我没有更好的结果。我认为问题在于当我创建一个新文档时,这会为我创建一个 html 过度结构,而我不需要它。
这是我的 JavaScript 代码:
var windowTab= window.open();
var blob = new window.Blob([response], { type: 'application/pdf' });
var file = URL.createObjectURL(blob);
windowTab.document.write('<object data="' + file + '" style="border:0px; margin:0px; padding:0px;
width:100%; height:100%;" allowfullscreen></object>')
这是生成的html:
<html>
<head>
</head>
<body>
<!-- This is my document !-->
<object data="blob:http://localhost:8080/f3a8347d-1052-4460-acc8-ecb8d6be0861" allowfullscreen="">
<!-- this html is unnecessary -->
<html>
<head></head>
<body>
<embed width="100%" height="100%" src="about:blank" type="application/pdf"
internalid="CAE747DCA94CCEFA3C50345F9D12986A">```</body>
</html>
</object>
</body>
</html>
解决方案
Try setting all border
to 0px
or none
body,
html,
object,
embed{
border: 0px !important;
}
推荐阅读
- python - QComboBox项及其值是其他文本框的功能,如何使用?
- javascript - 为什么 Firebase 命令不起作用?
- linux - MacOS 中的 Bash 脚本与 LInux 有何不同?
- php - Laravel 调用未定义的方法 App\\Model ::mapInto(), vendor\\laravel\\framework\\src\\Illuminate\\Support\\Traits\\ForwardsCalls.php
- c++ - MSVC 是否支持 C++11 样式的属性而不是 __declspec?
- python - for 关键字是否理解字符串是迭代?
- flutter - 如何在 post 方法中包含对象?HTTP
- android - Android如何创建梯形形状
- java - 在 Java 运算符方面需要一些帮助,得到“一元运算符的错误操作数类型 int”错误
- python - 带有池和上下文管理器的 Python 多处理