Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing contents of i-frame

Status
Not open for further replies.

chrismassey

Programmer
Joined
Aug 24, 2007
Messages
264
Location
GB
Hello,

I have a javascript print button which prints the contents of the window... However I want it to print the contents of the i-frame its placed above. I would put it inside the i-frame however I want this print button to appear no matter whats in the i-frame... Heres the orignal button...

Code:
<A HREF="javascript:window.print()><font face="Arial" size="2"><b>Click Here To Print</b></font></A><iframe src ="$i_frame_url" width="100%" height="100%" frameborder="0" name="contentframe"></iframe>

However the button will print the whole window... So I tried this...

Code:
<A HREF="javascript:window.print().target="contentframe"><font face="Arial" size="2"><b>Click Here To Print</b></font></A><iframe src ="$i_frame_url" width="100%" height="100%" frameborder="0" name="contentframe"></iframe>

Although this does not work.

Any suggestions?

Thank you
 
Hi

Code:
<a href="javascript:[red]contentframe[/red].print()">Click Here To Print</a>
When you post code, please remove the decorations like [tt]font[/tt] and [tt]b[/tt] tags. It is easier to read it and faster to post a solution.

Feherke.
 
The JS function
Code:
<script language=javascript>
function printMe(ptarget)
{
ptarget.focus();
ptarget.print();
}
</script>

The invoking button
Code:
<button onClick="print('YourIFrameName');">Print Iframe</button>

Olav Alexander Mjelde
Admin & Webmaster
 
Sorry, how noob of me..

You only need:
Code:
<button onClick="print('YourIFrameName');">Print Iframe</button>

Olav Alexander Mjelde
Admin & Webmaster
 
Hi,

Thank you very much for responding. I will try the javascript now. In future I will make sure I remove irrelevant tags within my code.

Thanks for your help

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top