從打印頁面中刪除網址並打印文本

[英]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