【发布时间】:2013-08-19 09:18:46
【问题描述】:
我正在努力解决一个问题,我希望你能帮助我。我创建了一个从页面输入中打印数据的函数。但是,我在打印页面上使用的徽标不会像图像链接损坏一样显示。有什么想法吗?
代码如下:
function printReport() {
win=null;
var vin = $("input[name='vin']").val();
var make = $("select[name='make']").val();
var printData = '<table width="960" border="0" align="center"> <tr> <td colspan="2"><img src="http://localhost/site/images/logo_print.png" width="291" height="109" /></td> </tr> <tr> <td colspan="2"><div class="print-title" align="center">Service report </div></td> </tr> <tr> <td width="196">Vin:</td> <td width="754"><b>'+ vin +'</b></td> </tr> <tr> <td>Make:</td> <td><b>'+ make +'</b></td> </tr> </table>';
win = window.open();
self.focus();
win.document.open();
win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');
win.document.write("body, td { height: 25px; font-family: 'PT Sans', sans-serif; font-size: 17px; color:#333333;} .logo{ background:url(http://localhost/clubdfrance/images/logo_print.png); background-repeat:no-repeat; display:block; width:291px; height:109px;} .print-title{ display:block; margin-top:10px; font-size: 25px; }");
win.document.write('<'+'/'+'style'+'><'+'/'+'head'+'><'+'body'+'>');
win.document.write(printData);
win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');
win.document.close();
win.print();
win.close();
【问题讨论】:
-
也许我的回答可以帮到你:stackoverflow.com/questions/20007595/…
标签: javascript image printing