How to remove the URL from the printing page?
Solution 1
Following code sample will work for you,
<style type="text/css" media="print">
@page {
size: auto; /* auto is the initial value */
margin: 0; /* this affects the margin in the printer settings */
}
</style>
see the answer on Disabling browser print options (headers, footers, margins) from page?
and specification of the @page
Solution 2
i found something in the browser side itself.
Try this steps. here i have been mentioned the Steps to disable the Header and footer in all the three major browsers.
Chrome Click the Menu icon in the top right corner of the browser. Click Print. Uncheck Headers and Footers under the Options section.
Firefox Click Firefox in the top left corner of the browser. Place your mouse over Print, the click Page Setup. Click the Margins & Header/Footer tab. Change each value under Headers & Footers to --blank--.
Internet Explorer Click the Gear icon in the top right corner of the browser. Place your mouse over Print, then click Page Setup. Change each value under Headers and Footers to -Empty-.
Solution 3
Having the URL show is a browser client preference, not accessible to scripts running within the page (let's face it, a page can't silently print themselves, either).
To avoid "leaking" information via the query string, you could submit via POST
Solution 4
If you set the margin for a page using the code below the header and footers are omitted from the printed page. I have tested this in FireFox and Chrome.
<style media="print">
@page {
size: auto;
margin: 0;
}
</style>
Solution 5
This helped me: Print page without links
@media print {
a[href]:after {
content: none !important;
}
}
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on December 31, 2020Comments
-
Admin over 3 years
I want to remove the URL that gets printed on the bottom of the page.
like:
yomari.com/.../main.php?sen_n
How can it be omitted or prevent from getting printed?
To be more specific, is there any way I can prevent the page URL, date and the page title being printed along, while printing the web page?
-
troelskn over 15 yearsnoooo ... POST is not an encryption mechanism - it's a hint about the possible side effects of the request.
-
Shoban over 15 yearsInstead of printhing a long multi line query string. I woul be happy to print just the url
-
troelskn over 15 yearsthe query string is part of the url. if the url is too long, you should fix that instead.
-
Vilius Surblys over 15 yearsI didn't say it was an encryption thing -- it does remove the query parameters from the URL, which was a requested mitigation factor
-
Mirzhan Irkegulov about 11 yearsOn Firefox 20.0 this doesn't remove URL from Print Preview
-
SearchForKnowledge almost 10 yearsI want to print part of the page (with styles) to PDF... How can I achieve that? stackoverflow.com/questions/25082395/…
-
Konstantin Vdovkin over 8 yearsFirefox solution: stackoverflow.com/questions/2192806/…
-
CompanyDroneFromSector7G over 8 yearsGreat answer. Even better just set the bottom margin, e.g.
margin-bottom: 0mm;
-
mehov over 7 yearsThis actually worked on my Firefox 50 @MirzhanIrkegulov
-
Pavel Nazarov over 6 yearsThe topic starter asked how to remove top and bottom colontitles (url page number title) a browser adds during the print preview.
-
Blaise about 6 yearsNote that this removes the margin between pages in Firefox. Example: i.imgur.com/krDlC1K.png
-
James Wong about 6 yearsHello welcome to SO, thank you for trying to answer this question. Can you provide more explanation behind your answer and the logic behind your fix? Cheers!
-
Pramod Wayal over 5 yearsthis code remove only margin .that's why url not display .but when you use this you loss the page number.
-
Pramod Wayal over 5 yearsi want to only remove page url on print not page number
-
M.suleman Khan about 5 yearscan you please explain this
-
Ruben S over 4 yearsIn what browser does this work? In Chrome 80 it doesn't work.
-
Mohsin almost 4 yearsI had a problem with bootstrap hyperlinks showing its href content on print page. This solution helped me fix the problem.
-
Tod Birdsall almost 4 yearsUsing your solution I still see the "domain-name.com" printed in the top right corner. It removed everything after that.
-
Tod Birdsall almost 4 yearsUpvoted because you include CSS that puts margins back in place. Thx!
-
Saman almost 4 yearsHi, Thanks, this works perfectly in chrome (at least), I don't know why people down voted this perfect solution.
-
Eliezer Berlin over 3 years@Saman Because this solution doesn't work except in extremely specific circumstances. Namely, if your header is called
#Header
and your footer is called#Footer
. This probably works OK in some wordpress templates, but it won't work well anywhere else. Besides which, it doesn't answer OP's question, which was about hiding the URL created by the browser, not the header/footer. I'm surprised it doesn't have more downvotes, frankly. -
Junaga over 2 yearsThis does not work inside SPAs, because the client side router changes the view before it can be printed.
-
Sohail Sajid over 2 yearsworked like a charm. Thank you
-
Flimm over 2 yearsThis doesn't work in all browsers: caniuse.com/css-paged-media
-
royallife over 2 yearsHow I can only remove the url but not the page number from the footer?
-
Ezz Redfox about 2 yearsfor some reason i can't determine, this doesn't work for me.