How to print all frames on the page in one file

2019-09-09 00:37发布

I am using frameset tag and i want to print all frames inside the frame set

<html>
     <frameset rows="10%,*">
       <frame name="top_frame" src="top-frame.htm" frameborder="1" noresize="0" scrolling="no">
       <frameset cols="20%,*">
          <frame name="left_frame" src="left-frame.htm" frameborder="0" noresize="0" scrolling="no">
          <frame name="right_frame" src="right-frame.htm" frameborder="0" noresize="0" scrolling="auto">
       </frameset>
    </frameset>
</html>

I used parent.window.focus();parent.print(); it works in Chrome, but in IE11 it prints each frame in one file.

any suggestion?

I also used parent.window.focus();window.print(); but it doesn't work in both.

1条回答
混吃等死
2楼-- · 2019-09-09 01:00

This should work:

try{
    document.execCommand('print', false, null);
}
catch(e){
    window.print();
}

Source link

查看更多
登录 后发表回答