iframe content gets cut off when printing

前端 未结 5 970
谎友^
谎友^ 2021-01-05 11:56

I have a page with an iframe in it. The iframe\'s content is a couple of pages long, I\'ve set the iframe\'s height to match it\'s content. When I try to print the page, the

5条回答
  •  孤城傲影
    2021-01-05 12:21

    Here is a simple solution using javascript to manipulate the DOM and set the current window to equal the iframe's window, then issue the print command.

    
    
    
    
    
    
    
    
    
    
    
    

    Remember that in your parent page HTML you will have the code below to call the printPage function.

    
    

    With this solution you avoid the problem of the iframe being cut off if it exceeds one page. Secondly, you get only one print dialogue box even if you have multiple iframes.

提交回复
热议问题