how to print all frames inside frameset/nested frameset with javascript
Asked Answered
A

0

0

I have a nested frameset and i what to print all frames with one print button, i searched and tried many solutions which mentioned, but still I have problem with the IE 11. any one can help me please. my code is here. ---main page

<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>

---top-frame.htm:

<html>
<body>
   <div id="app_banner" style="width:50%; border:1px solid #000; height:50px; padding:2px 10px;">
     <span id="app_provider">Company Name</span>
     <input style="float:right" type="button" value="Print" onclick="javascript:window.print();">
   </div>
</body>
</html>

---left-frame.htm:

<html>
<head>
</head>
<body>
<table border="1">
  <tr><td>test left</td><td>123</td></tr>
  <tr><td>test left</td><td>352</td></tr>
  <tr><td>test left</td><td>542</td></tr>
  <tr><td>test left</td><td>2345</td></tr>
  <tr><td>test left</td><td>5432</td></tr>
</table>
</body>
</html>

---right-frame.html:

<html>
<head>
</head>
<body>
    <table border="2">
        <tr><td>test right</td><td>1234</tr>
        <tr><td>test right</td><td>4321</td></tr>
        <tr><td>test right</td><td>5678</td></tr>
        <tr><td>test right</td><td>8765</td></tr>
        <tr><td>test right</td><td>345</td></tr>
    </table>
    </body>
</html>

when i click the print button, it just prints the "top-frame.htm" not all frames. I need to print all the frames.

Note: I used the parent.print(), top.window.print(), focus before print and parent['top_frame'] as well, but it works in Chrome but not in IE11, which my clients use IE.

Argillaceous answered 30/6, 2015 at 7:40 Comment(8)
In IE you've to focus the window you're about to print, before printing.Forth
oh sorry i used focus as well but still is not workingArgillaceous
Have you tried top.window.print()?Forth
I just tried it now, but not workingArgillaceous
Teemu it just print the top-frame onlyArgillaceous
I used onclick="top.window.focus();top.window.print();" again it works in Chrome, but in IE it prints each frame in one file, so how can i concatenate the filesArgillaceous
Open File | Print Preview ..., there's a dropdown, from which you can select how to print the frames on a page.Forth
Please re-read my previous comment. It's a user's preference, what actually is printed.Forth

© 2022 - 2024 — McMap. All rights reserved.