How to remove the URL from the printing page?

262,640

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;
    }
}
Share:
262,640
Admin
Author by

Admin

Updated on December 31, 2020

Comments

  • Admin
    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
    troelskn over 15 years
    noooo ... POST is not an encryption mechanism - it's a hint about the possible side effects of the request.
  • Shoban
    Shoban over 15 years
    Instead of printhing a long multi line query string. I woul be happy to print just the url
  • troelskn
    troelskn over 15 years
    the query string is part of the url. if the url is too long, you should fix that instead.
  • Vilius Surblys
    Vilius Surblys over 15 years
    I 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
    Mirzhan Irkegulov about 11 years
    On Firefox 20.0 this doesn't remove URL from Print Preview
  • SearchForKnowledge
    SearchForKnowledge almost 10 years
    I want to print part of the page (with styles) to PDF... How can I achieve that? stackoverflow.com/questions/25082395/…
  • Konstantin Vdovkin
    Konstantin Vdovkin over 8 years
  • CompanyDroneFromSector7G
    CompanyDroneFromSector7G over 8 years
    Great answer. Even better just set the bottom margin, e.g. margin-bottom: 0mm;
  • mehov
    mehov over 7 years
    This actually worked on my Firefox 50 @MirzhanIrkegulov
  • Pavel Nazarov
    Pavel Nazarov over 6 years
    The topic starter asked how to remove top and bottom colontitles (url page number title) a browser adds during the print preview.
  • Blaise
    Blaise about 6 years
    Note that this removes the margin between pages in Firefox. Example: i.imgur.com/krDlC1K.png
  • James Wong
    James Wong about 6 years
    Hello 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
    Pramod Wayal over 5 years
    this code remove only margin .that's why url not display .but when you use this you loss the page number.
  • Pramod Wayal
    Pramod Wayal over 5 years
    i want to only remove page url on print not page number
  • M.suleman Khan
    M.suleman Khan about 5 years
    can you please explain this
  • Ruben S
    Ruben S over 4 years
    In what browser does this work? In Chrome 80 it doesn't work.
  • Mohsin
    Mohsin almost 4 years
    I had a problem with bootstrap hyperlinks showing its href content on print page. This solution helped me fix the problem.
  • Tod Birdsall
    Tod Birdsall almost 4 years
    Using your solution I still see the "domain-name.com" printed in the top right corner. It removed everything after that.
  • Tod Birdsall
    Tod Birdsall almost 4 years
    Upvoted because you include CSS that puts margins back in place. Thx!
  • Saman
    Saman almost 4 years
    Hi, Thanks, this works perfectly in chrome (at least), I don't know why people down voted this perfect solution.
  • Eliezer Berlin
    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
    Junaga over 2 years
    This does not work inside SPAs, because the client side router changes the view before it can be printed.
  • Sohail Sajid
    Sohail Sajid over 2 years
    worked like a charm. Thank you
  • Flimm
    Flimm over 2 years
    This doesn't work in all browsers: caniuse.com/css-paged-media
  • royallife
    royallife over 2 years
    How I can only remove the url but not the page number from the footer?
  • Ezz Redfox
    Ezz Redfox about 2 years
    for some reason i can't determine, this doesn't work for me.