【问题标题】:window.print image in a linkwindow.print 链接中的图像
【发布时间】:2014-05-11 14:20:30
【问题描述】:

所以我有这个:

<script>
   window.print();
</script>

我想打印这个网址的图片:

http://www.somefancyurl.com/labels/postage/45029dd.png

该页面只显示我要打印的图像。

我试过了:

<script>
   window.print('http://www.somefancyurl.com/labels/postage/45029dd.png');
</script>

但这似乎并没有改变什么。

多亏了一些搜索,我想出了这个:

function printLabel(){

   popup = window.open();
   popup.document.write('<?php echo $order->shipmentLabel; ?>');
   popup.print();

   return false;
}

但这会尝试打印出&lt;?php echo $order-&gt;shipmentLabel; ?&gt; 而不是实际图像。

【问题讨论】:

标签: javascript printing


【解决方案1】:

在页面中,编写html代码,如

<html>
<body>
<img src='http://www.somefancyurl.com/labels/postage/45029dd.png' />
</body>
</html>

并将脚本编写为

<script>
   window.print();
</script>

【讨论】:

    【解决方案2】:

    您不能直接打印图像。

    你应该这样做:

    <script>
       window.print();
    </script>
    <img src="http://www.somefancyurl.com/labels/postage/45029dd.png" />
    

    您也可以在新窗口中执行此操作。(弹出)

    【讨论】:

      猜你喜欢
      • 2012-12-14
      • 1970-01-01
      • 2010-12-25
      • 1970-01-01
      • 2019-08-30
      • 2018-03-17
      • 2011-08-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多