Open a new javascript window(.open) along with its CSS styling

后端 未结 6 500
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 18:50

I\'m trying to get this function to work on the website of a project I\'m working on. The purpose of this function is to only (physically) print the contents of a child div

6条回答
  •  没有蜡笔的小新
    2020-11-27 19:17

    I wanted to have all the styles from the parent page and print. So I wanted to use all the css links in the HEAD.

    My solution uses jQuery.

    (function print() {
        // getting the tag element I want to print
        // cloning the content so it doesn't get messed
        // remove all the possible scripts that could be embed
        var printContents = $('body').clone().find('script').remove().end().html();
    
        // get all  and remove all the 
    
                                     
                  
提交回复
热议问题