Print
only?

前端 未结 30 1626
暖寄归人
暖寄归人 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:44

    base on @Kevin Florida answer, i made a way to avoid script on current page disable because of overwrite content. I use other file called "printScreen.php" (or .html). Wrap everything you want to print in a div "printSource". And with javascript, open a new window you created before ("printScreen.php") then grab content in "printSource" of top window.

    Here is the code.

    Main window :

    echo "
    "; //everything you want to print here echo "
    "; //add button or link to print echo "";

    This is "printScreen.php" - other file to grab content to print

    
    // write everything about style/script here (.css, .js)
    
    
    
    
    
    
    
    

提交回复
热议问题