How to print a portion of an HTML page?

前端 未结 4 1794
Happy的楠姐
Happy的楠姐 2021-01-13 06:35

I have an html page i want to print a portion of this html page, I know a javascript function to print a page,

onClick=\"javascript:window.print(); return fa         


        
4条回答
  •  隐瞒了意图╮
    2021-01-13 07:10

    You should use a separate css for the print media. This allows you to hide/show portions of the page when it gets printed.

    html :

    blah
    print this!

    include:

    
    

    print.css

    .dont-print-that{display:none;}
    

    The other solution is to open a new window with only the content you want to print. You could either do that in a popup or an iframe. Personally I find the CSS solution more elegant, but that's up to you.

提交回复
热议问题