Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > window.print and iframe

Reply
Thread Tools

window.print and iframe

 
 
Lamberti Fabrizio
Guest
Posts: n/a
 
      05-26-2004
Hi all,
I've got this problem.

I've an ASP file, named content.asp, with inside an input button and a
iframe that loads another asp file, named iframe.asp

I'd like printing iframe.asp using the button inside content.asp.

The size of iframe object inside content.asp is smaller than the real size
of iframe.asp so I can't use JSCRIPT code window.print for the input button.

How can I solve my problem ?

regards


 
Reply With Quote
 
 
 
 
DU
Guest
Posts: n/a
 
      06-01-2004
Lamberti Fabrizio wrote:

> Hi all,
> I've got this problem.
>
> I've an ASP file, named content.asp, with inside an input button and a
> iframe that loads another asp file, named iframe.asp
>
> I'd like printing iframe.asp using the button inside content.asp.
>
> The size of iframe object inside content.asp is smaller than the real size
> of iframe.asp so I can't use JSCRIPT code window.print for the input button.
>
> How can I solve my problem ?
>
> regards
>
>



Assuming you have this markup in your content.asp file:

<p><button type="button" onclick="PrintIframe();">Print the content of
the iframe</button></p>
<iframe name="IframeName" src="iframe.asp" ...></iframe>

then in your <head> include this:

<script type="text/javascript">
function PrintIframe()
{
frames["IframeName"].focus();
frames["IframeName"].print();
}
</script>

1- Note that content.asp and iframe.asp must share the same domain
otherwise you'll be prevented to print because of the scripting across
domain security constraint:
"when loading a document from one origin, a script loaded from a
different origin cannot get or set specific properties of specific
browser and HTML objects in a window or frame"
http://devedge.netscape.com/library/...c.html#1015705

2- Last time I checked this issue (~ 6 months ago or so), Opera 7.x was
not printing iframe but this could have been fixed since then. The code
works for NS 7.x, Mozilla 1.3+, MSIE 6.

DU
 
Reply With Quote
 
 
 
 
lebohang lebohang is offline
Junior Member
Join Date: Mar 2009
Posts: 3
 
      03-04-2009
Hi,

Just to add to this post. If the print button is on a different frame from the frame that contains your iframe (but in the same domain). then you can use:

parent.frames['frameName'].window.frames['IframeName'].focus();
parent.frames['frameName'].window.frames['IframeName'].print();

Hope this helps.

Quote:
Originally Posted by DU
Lamberti Fabrizio wrote:

> Hi all,
> I've got this problem.
>
> I've an ASP file, named content.asp, with inside an input button and a
> iframe that loads another asp file, named iframe.asp
>
> I'd like printing iframe.asp using the button inside content.asp.
>
> The size of iframe object inside content.asp is smaller than the real size
> of iframe.asp so I can't use JSCRIPT code window.print for the input button.
>
> How can I solve my problem ?
>
> regards
>
>



Assuming you have this markup in your content.asp file:

<p><button type="button" onclick="PrintIframe();">Print the content of
the iframe</button></p>
<iframe name="IframeName" src="iframe.asp" ...></iframe>

then in your <head> include this:

<script type="text/javascript">
function PrintIframe()
{
frames["IframeName"].focus();
frames["IframeName"].print();
}
</script>

1- Note that content.asp and iframe.asp must share the same domain
otherwise you'll be prevented to print because of the scripting across
domain security constraint:

2- Last time I checked this issue (~ 6 months ago or so), Opera 7.x was
not printing iframe but this could have been fixed since then. The code
works for NS 7.x, Mozilla 1.3+, MSIE 6.

DU
 
Reply With Quote
 
AGN AGN is offline
Junior Member
Join Date: Jan 2011
Posts: 3
 
      01-28-2011
i cant print from iframe.print() in a pdf file in IE.please give me a solution,i tried self.print(),window.print etc.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page and Iframe, wait for iframe to load before manipulating the DOM BerlinBrown Javascript 5 02-05-2008 10:40 PM
Targeting a parent iframe from a sub-iframe albanitus@yahoo.com HTML 0 11-15-2006 04:40 PM
parent/iframe set iframe source and submit form superfreaker@gmail.com Javascript 2 03-09-2006 11:05 PM
IFRAME initalization and stylesheet in DOM-created IFRAME Vincent van Beveren Javascript 7 07-11-2004 01:04 AM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM



Advertisments