问题描述
我开发了一个网络应用程序,在我的网页中有一些数据显示常见的页眉、页脚、菜单和其他图像.所以我添加了一个小按钮作为打印预览,以便用户只能看到数据.用户点击打印预览按钮后只显示数据作为弹出窗口,在该弹出窗口中我添加了一个按钮调用打印,以便用户可以单击它并从该页面打印出来.
I have developed a web application and in my web page there are some data displays withcommon headers, footers , menus and other images. so I have added a small button as printpreview so that user only can see data. After user click on print preview button only data displayas a popup and in that popup I added a button call print so that user can click on it and take a print out of that page.
这个打印按钮在 onClick 事件中直接调用 window.print() 并且它工作正常我可以得到打印输出.
this print button directly call to window.print() in onClick event and it working fine I can get the print outs.
但我的问题是在我的打印页面之上,我可以找到按钮标题和上面的打印"文本我可以找到 url,它是 http://localhost/........
but my problem is in my printed page on top of that I can find the "Print" text which is button caption and in above thatI can find the url which is something http://localhost/..............
那么有没有办法从我的打印页面中删除那些打印文本和网址.
So is there a way that I can remove those print text and url from my printed page.
非常感谢
这就是打印预览按钮的作用.
this is what the print preview button do .
function printPreView(reportCategory,reportType,transactionType,searchOption,customerRokaID,utilityCompany,fromDate,toDate,telcoName,bank){
var request = "selectedMenu="+reportCategory+"&loginStatus=success&criteria="+searchOption+"&customer="+customerRokaID+"&from="+fromDate+"&to="+toDate+"&nspTypes="+utilityCompany+"&trxTypes="+transactionType+"&options="+reportType+"&telcoTypes="+telcoName+"&bankTypes="+bank+"&printable=yes";
window.open ("report/showReport.action?"+request,null,"location=no,menubar=0,resizable=1,scrollbars=1,width=600,height=700");
}
这是我放置打印按钮的方式
Here is how I have put my Print button
<form>
<input type="button" value="Print" onClick="window.print() ">
</form>
推荐答案
带有 URL 的标题(有时还有页面标题、页码等)由 Web 浏览器自动添加.基本上,设置只能由用户更改.在那个问题
The header with the URL (and sometimes the page title, page number etc.) is automatically added by the web browser. Basically the settings can only be changed by the user. This topic is discussed in details in that question
对于按钮本身,您可以使用特定的打印 CSS 隐藏它,如 那个问题.正如 MMacdonald 所说,您也可以将此技术用于其他元素,这样您就无需重新呈现页面.但是这样你就会失去预览功能(用户仍然可以使用浏览器的打印预览功能).
For the button itself, you could hide it using specific print CSS as discussed in that question. And as MMacdonald said, you can use this technique for other elements as well so that you don't need to re-render your page. But then you would lose the preview feature (the user could still use the browser's print preview feature).
这篇关于从打印页面中删除 url 并打印文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!