从打印页面中删除网址并打印文本

[英]remove url and print text from the printed page


I have developed a web application and in my web page there are some data displays with common headers, footers , menus and other images. so I have added a small button as print preview so that user only can see data. After user click on print preview button only data display as 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.

我开发了一个Web应用程序,在我的网页上有一些数据显示,包括常见的页眉,页脚,菜单和其他图像。所以我添加了一个小按钮作为打印预览,以便用户只能看到数据。用户单击打印预览按钮后,仅将数据显示为弹出窗口,并在该弹出窗口中添加了一个按钮调用打印,以便用户可以单击它并从该页面打印出来。

this print button directly call to window.print() in onClick event and it working fine I can get the print outs.

这个打印按钮直接调用onClick事件中的window.print(),它工作正常,我可以得到打印输出。

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 that I can find the url which is something http://localhost/..............

但我的问题是在我的打印页面上,我可以找到“打印”文本,这是按钮标题,在上面,我可以找到的URL是http:// localhost / ........ ......

So is there a way that I can remove those print text and url from my printed page.

那么有没有办法可以从我的打印页面中删除那些打印文本和网址。

Many Thanks

非常感谢

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>

3 个解决方案

#1


8  

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

带有URL的标题(有时是页面标题,页码等)由Web浏览器自动添加。基本上,设置只能由用户更改。该问题详细讨论了该主题

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).

对于按钮本身,您可以使用特定的打印CSS将其隐藏,如该问题中所述。正如MMacdonald所说,您也可以将此技术用于其他元素,这样您就不需要重新渲染页面了。但是你会失去预览功能(用户仍然可以使用浏览器的打印预览功能)。

#2


3  

If you're using bootstrap, find following code:

如果您使用的是bootstrap,请查找以下代码:

 @media print {
  ...
  a[href]:after {
    content: " (" attr(href) ")";
  }
  ...
}

Overriding the style with content:none handles the situation fine.

用内容覆盖样式:none处理好情况。

Reference: this url

参考:这个网址

#3


1  

Consider using media-dependent style sheets instead of making a bespoke "print page" solution.

考虑使用与媒体相关的样式表,而不是制作定制的“打印页面”解决方案。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/10/30/4f562ad74150a77c4f42c9d62ca3219f.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com