473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

IE7 Printing Iframe Solution

Dear All,

I was looking for a solution to print Iframes in Internet Explorer 7 (IE7)

the command window.print() ( even with window.focus) in an iframe does not work.

The solution is
<script language=javascipt>

document.execCommand('print', false, null);

</script>

I spent alot wasted time figuring this out, hope it helps!

best regards,

Ariel

I am considering making Goofi.com free, any ideas on a revenue model?
Goofi is a Live Chat for website with Audio and Video to comunicate with consumers before a sale.
Apr 9 '07 #1
6 28301
You are the man!! It works!!
Jan 2 '08 #2
q1712
2
used it this way:
Expand|Select|Wrap|Line Numbers
  1.         <script type="text/javascript">
  2.             try
  3.             {
  4.                 document.execCommand('print', false, null);
  5.             }
  6.             catch(e)
  7.             {
  8.                 window.print();
  9.             }
  10.         </script>
  11.  
works perfectly, thanks.
Jun 26 '09 #3
I am in your debt.

Also, I think this might clarify q1712's example if your code executed from the window containing the iframe, as mine is:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.             try
  3.             {
  4.                 iframe = document.getElementById('iframe-id');
  5.                 iframe.contentWindow.document.execCommand('print', false, null);
  6.             }
  7.             catch(e)
  8.             {
  9.                 window.print();
  10.             }
  11. </script>
Sep 25 '10 #4
q1712
2
i got an email when leif send his reply.

he was a PRO using the information the righ way (thx 4 converting it to a parent-frame-script)

anway, there is still an issue i solved, that may be of intrest:

one vession of the windoof-browser (IE7) was not able (able but not willing) to print anything that wasn't rendet.

that means: i always got the printer to print, but sometimes it was an emty page.

so: use this script as an "onload-funtion" put it at the end of the "<body>-tag" or just give it a timeout.

i'd like to post the the script, but i was 2able2 keep my job, and i'll never ever steal code form my former employ.
Sep 30 '10 #5
Thank you for saving me time. May i add this is the only code that will print full frame in IE8 and IE9.

parent.framename.print(); does not work.
window.print(); does not work.

The above only prints a portion of the visible frame, if you have scrolling it does not print the rest of the page.

Here is my print frame solution based on your code

In head:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     function printfrm() {
  3.         document.execCommand('print', false, null);
  4.     }
  5. </script>
  6.  
Then in the body:

Expand|Select|Wrap|Line Numbers
  1. <input type="button" value="Print this page" onClick="printfrm();" />
  2.  
Aug 30 '12 #6
what if we have more than 1 iframe in a page.how can i print all the content of iframe without truncating.
Sep 9 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Marina Ferguson | last post by:
Hi, I have a document with an iframe. The main doc has a "Print" button. The idea is that when the user clicks it, the contents of the iframe is printed. For some reason instead of the iframe...
0
by: Vince | last post by:
I have a generic page that I use for printing content, and it contains an iframe into which I put the url for the page to be printed. I dynamically size the iframe so that it correctly displays...
2
by: nightstar | last post by:
I am creating a web page that will contain multiple Iframes. One of the Iframes will contain a bill of sale that is generated by a script on x.mydomain.com/somefile.php?someparameters. One of the...
1
by: Poonam | last post by:
Hi I have a page where there is table and below the table there is 'iframe', This page also has 'Print' button. Printing this page is printing the table and iframe contents on 2 different...
10
by: jon | last post by:
I'm trying to use a hidden iframe to print the contents of one div seamlessly. Currently I can create the hidden iframe, copy the contents of the div to the iframe, and print it. I even have a...
1
by: DevGeeta | last post by:
Hi, I have one page with Iframe ...The issue is to Print a page with all data from Iframe also. I tried doing window.print() this print whole page.But not all data from Iframe. Also when...
8
by: jay123 | last post by:
hello, i really need help from you experts. my problem is i have one page abc.aspx, and then their is other page called def.aspx(which is printable version), which gives some information used...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.