Print
only?

前端 未结 30 1670
暖寄归人
暖寄归人 2020-11-22 00:25

How do I print the indicated div (without manually disabling all other content on the page)?

I want to avoid a new preview dialog, so creating a new window with this

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 00:52

    Sandro's method works great.

    I tweaked it to allow for allowing multiple printMe links, particularily to be used in tabbed pages and expanding text.

    function processPrint(printMe){ <-- calling for a variable here

    var printReadyElem = document.getElementById(printMe); <-- removed the quotes around printMe to ask for a variable

    Print <-- passing the div ID to be printed on to the function to turn the printMe variable into the div ID. single quotes are needed

提交回复
热议问题