【发布时间】:2015-02-12 10:06:46
【问题描述】:
在我的 laravel 项目中,我需要打印出医生的处方。为此,我已经创建了标题部分并保存在数据库中。当用户单击 div 旁边的打印机图标时,该 div 内的内容需要与保存的标题一起打印。
使用的方法是:在包含打印机图标的视图部分
<div class="AnswerBlock"><div class="NmaeDate">
<span class="name"><?php echo 'Prescription :'; ?></span><span style="float:right;"><a href="<?php echo URL::to('/user/print-prescription',array($id,1));?>"><img src="<?php echo asset('images/footericons/printout.png'); ?>" title="prescription1" alt="take print" width="20" height="20"></a></span>
<div class="answer">
<?php echo stripslashes($data1->prescription1);?>
</div>
</div>
</div>
在用户控制器中:
public function anyPrintPrescription($eid='',$no=''){
$drpres='';
$prs = DB::table('appoint')->where('id','=',$eid)->first();
if($no=='1'){
$drpres = $prs->prescription1;
}
elseif($no=='2'){
$drpres= $prs->prescription2;
}
elseif($no=='3'){
$drpres = $prs->prescription3;
}
$presheader = Admin::where('id','=',$prs->d_id)->pluck('prescription_header');
return View::make('con.printout_prescription')->with(array('presc'=>$drpres,'phead'=>$presheader));
}
视图是:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
.print:last-child {
page-break-after: auto;
}
</style>
</head>
<body onload="window.print()">
<div class="print"><?php echo $phead;?></div>
<div class="print"><?php echo $presc;?></div>
</body>
</html>
我得到的输出是:单击打印图标时,打印机选项提示窗口正在打开。但同时浏览器会转到查看 url 并显示它。
有谁知道如何让窗口不显示视图?
【问题讨论】: