Php 打印文章 同一张图片显示在不同的页面?
一般php打印东西,都是重新生成一个新的页面,显示打印的内容
打印文字,打印表格(表格的边框,背景显示需要打印机的设置配合)都不是问题,打印文章的时候确出现了同一张图片显示在不同的页面,习惯是把文章内容放在一个table 里,这就是原因呀,chrome是这样的,firefox确实分页放置的。把表格去掉,就显示正常了
<html> <head> <title>打印文章-$article[title]</title> <style type="text/css"> <!-- body { text-align: center; font-size: 12px; } h1{ font-size:16px;} #main_line{ 780px; margin:0 auto; position: relative; padding:50px 0; text-align:left;} #main_line .title{ text-align:center;} #content{ font-size:12px; line-height:20px; 100%;} #content img{ max-700px;} #print_btn{ text-align:right; position: fixed; top:0; right:0; background-color:#3e3e3e; height:30px; line-height:30px; padding-left:10px;} #print_btn a{ margin-right:20px; text-decoration: none; color:#fff; font-size:14px;} #print_btn a:hover{ color:#f00;} #print_btn span{ color:#fff; font-size:12px; margin-right:20px; display:inline-block;} #print_btn span a{ font-size:12px; margin:0 10px 0 0;} #print_btn .fontsize_control a{ padding:5px;} --> </style> </head> <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" oncontextmenu="return false" ondragstart="return false"> <div id="main_line" style="780px;"> <div id="print_btn"> <span class="fontsize_control"> 字号 <a href="javascript:;" onclick="javascript:fontZoomB();">++</a><a href="javascript:;" onclick="javascript:fontZoomA();">--</a> </span> <span> 打印类型: <a href="javascript:;" onclick="javascript:showConType(0);">图文</a> <a href="javascript:;" onclick="javascript:showConType(1);">仅文字</a> <a href="javascript:;" onclick="javascript:showConType(2);">封面图+文字</a> </span> <a href="javascript:;" onclick="javascript:showPrinter();">打印</a><a href="javascript:window.close();">关闭窗口</a> </div> <div class="title"> <h1>$article[title]</h1> <p>发布者:$article[username]<!--{if $article[from]}--> <span>|</span> {lang from}: $article[from]<!--{/if}--> <span>|</span> 发布时间:$article[dateline]</p> </div> <div id="content"> <!--{if $type == 1}--> $contentstr_noimg <!--{else if $type == 2}--> $contentstr_onlypic <!--{else}--> $contentstr <!--{/if}--> </div> </div> <div style="display:none"> <table id="contentType0"><tr><td>$contentstr</td></tr></table> <table id="contentType1"><tr><td>$contentstr_noimg</td></tr></table> <table id="contentType2"><tr><td>$contentstr_onlypic</td></tr></table> </div> <script src="http://www.pimei.com/static/pimei/js/jquery-1.6.2.min.js" type="text/javascript"></script> <script type="text/javascript"> //双击鼠标滚动屏幕的代码 var currentpos,timer; function initialize() { timer=setInterval ("scrollwindow ()",30); } function sc() { clearInterval(timer); } function scrollwindow() { currentpos=document.body.scrollTop; window.scroll(0,++currentpos); if (currentpos !=document.body.scrollTop) sc(); } document.onmousedown=sc document.ondblclick=initialize //更改字体大小 var status0=''; var curfontsize=10; var curlineheight=18; function fontZoomA(){ if(curfontsize>8){ document.getElementById('content').style.fontSize=(--curfontsize)+'pt'; document.getElementById('content').style.lineHeight=(--curlineheight)+'pt'; } } function fontZoomB(){ if(curfontsize<64){ document.getElementById('content').style.fontSize=(++curfontsize)+'pt'; document.getElementById('content').style.lineHeight=(++curlineheight)+'pt'; } } //按钮层隐藏,显示打印机 function showPrinter() { $('#main_line').css('padding-top','0'); $('#main_line').css('padding-bottom','0'); $('#print_btn').remove(); window.print(); } // 更换打印类型 var contentType0 = $('#contentType0 tr td').html(); var contentType1 = $('#contentType1 tr td').html(); var contentType2 = $('#contentType2 tr td').html(); function showConType(type) { if(type == 1) { $('#content').html(contentType1); } else if(type == 2) { $('#content').html(contentType2); } else { $('#content').html(contentType0); } } </script> </body> </html>