Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IFRAME的打印内容_Javascript_Html - Fatal编程技术网

Javascript IFRAME的打印内容

Javascript IFRAME的打印内容,javascript,html,Javascript,Html,我正在尝试打印iframe中的内容。下面的代码工作正常 HTML: <div id="containerDiv"> <p> <table cellpadding="1" width="100%" height="100%" cellspacing="0" border="0"> <tr>

我正在尝试打印iframe中的内容。下面的代码工作正常

HTML:

  <div id="containerDiv">           
            <p> 
                <table cellpadding="1" width="100%" height="100%" cellspacing="0" border="0">                
                 <tr>
                   <td align="right" ><img src="Images/printer1.png" alt="Print" id="imgprint" onclick="printticket()" style="display:none;cursor:pointer;padding-top:2px;" /></td>
                 </tr>
                 <tr>
                  <td align="center">
                    <iframe id="OverlayDis" name="OverlayDis" scrolling="yes" src="Default1.aspx" allowtransparency="true"
                    runat="server" frameborder="0" style="background-color: white; width: 980px; height: 500px;"></iframe>
                  </td>
                 </tr>
                 <tr>
                   <td align="center"><input type="button" style="background-color:#400000;border:solid 1px black;color:White;font-weight:bold" id="closeLink" href="javascript:void(0);" value="Close"/></td>  
                 </tr>
                </table>
            </p>
        </div>  
  window.frames["OverlayDis"].focus();
  window.frames["OverlayDis"].print();
但是我的字体大小有问题。可见字体大小不是硬拷贝的。页面的所有文本大小都是12px,但输出打印的字体大小是8pt或更小

发生了什么事

 @media print
    {
      body{font-family:verdana; font-size:10px;}
      span.subheader{font-family: Verdana; font-size: 12px; font-weight: bold;}  
      span.sign{float:right;padding-right:20px;padding-top:20px;font-size:12px;font-weight:20px;font-weight: bold;}
    }

    @media screen
    {
      body{font-family:verdana; font-size:10px;}
      span.subheader{font-family: Verdana; font-size: 12px; font-weight: bold;}
      span.sign{float:right;padding-right:20px;padding-top:20px;font-size:12px;font-weight:20px;font-weight: bold;}
    }
我把这个样式添加到我的页面上进行打印,但由于字体太小,打印仍然不起作用。另一件事是我使用了lightbox插件来显示这个框架

var test;
Event.observe(window, 'load', function () {
    test = new Lightbox('containerDiv');
});

function OpenOverlay(url)
{   
    document.getElementById('OverlayDis').src = url;
    test.open();

    Event.observe('closeLink', 'click', function () {
        test.close();
    });
}

我的错误是什么?

iframe
的文档中使用a。

我更改弹出窗口而不是iframe,并使打印和关闭立即生效

窗口弹出窗口是否有其他选项?