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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing an iFrame

Status
Not open for further replies.

GIGN

Programmer
Oct 6, 2000
1,082
NZ
So what's going on with printing an iFrame - MSDN does not mention this onject even having this method - which I am incredulous at.

I want to be able to load text documents for printing you see - but if I can't print them, that's no good at all.
b2 - benbiddington@surf4nix.com
 
No, but I will, thanks, Bj.
b2 - benbiddington@surf4nix.com
 
I tried onLoad="this.print()" which returned, 'object does not support this property or method' - indicating to me, I think; that it is not possible to do so, which I find a little annoying. Maybe in the future! ;)
b2 - benbiddington@surf4nix.com
 
bangers,

this in your example above is referring to the window object. now if you want to do it like that, try something like:

function printIt()
{
if(this.document.readyState=="complete")
{
this.print()
}
}

iframeobj.onreadystatechange = printIt

when you assign an event handler through script, this refers to the object the event is for... jaredn@subdimension.com -
 
Oh sorry - I meant I used

<iframe onLoad=&quot;this.print()&quot;...>

Does this change what you mean?
b2 - benbiddington@surf4nix.com
 
bangers,

this in your example above is referring to the window object. now if you want to do it like that, try something like:

function printIt()
{
if(this.document.readyState==&quot;complete&quot;)
{
this.print()
}
}

iframeobj.onreadystatechange = printIt

when you assign an event handler through script, this refers to the object the event is for...

oops, messed up the TGML last time... what i'm saying is the this keyword, in event handlers designated with the following syntax:

<body onload=&quot;x=this.something&quot;>

is referring to the property something of window, while when you use the following syntax:

function someFunction()
{
x=this.something
}

document.body.onload=someFunction

this is referring to property something of document.body

if you are still confused, or want to know more about why this is true, let me know
jaredn@subdimension.com -
 

I totally agree with what you're saying - but I am sure I am not referring to the outside window..
if
<iframe onLoad=&quot;this.print()&quot;...> is calling the window's print function, then why didn't it print?

The thing is - I called it from inside the iframe object, to me meaning that this refers to the iframe.

As a test - I called:
<iframe onLoad=&quot;alert(this.name)&quot; name='Frame_1'...>

and this gave me &quot;Frame_1&quot;, not the main window name? Are we at crossed purposes here? :)
b2 - benbiddington@surf4nix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top