【问题标题】:how to print the contents of a hidden iframe?如何打印隐藏 iframe 的内容?
【发布时间】:2023-03-09 22:42:01
【问题描述】:

我想打印一个放在 iframe 中但不希望内容显示在网页中的页面,但是当我将 iframe 放入 display='none' 时,打印按钮不起作用

我做了什么:- 我设置了 iframe 样式='none'

"名称="frame1" >
<input type="button" onclick="frames['frame1'].print()" value="print!">

如何打印 iframe 的内容而不显示在网页上,或者说隐藏 iframe

非常感谢任何帮助.....

【问题讨论】:

    标签: php html css ajax iframe


    【解决方案1】:

    您打印了一个 css 文件,但在该文件中您没有 display: none 样式。

    <link rel="stylesheet" type="text/css" href="/css/print.css" media="print" />
    

    Here's a link to media types,感谢 Dror。

    【讨论】:

    【解决方案2】:

    您可以尝试使用 visibility: hidden 并将宽度和高度分别设置为 1px,而不是 display: none。

    【讨论】:

      猜你喜欢
      • 2011-06-16
      • 2011-01-14
      • 1970-01-01
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-27
      • 2014-02-27
      相关资源
      最近更新 更多