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 a frame from Opera (v.9)

Status
Not open for further replies.

tjw2006

Programmer
Nov 16, 2006
103
GB
Can't seem to get Opera to print a particular frame. The following code works in IE & Firefox:

(tr's the frame name)
parent.tr.print();

have tried:
top.frames['tr'].print();

and:
parent.frames['tr'].print();

but nothing works, just prints all frames, one on each page. Anybody had any success with Opera and printing frames?

Thanks
 
There are some restrictions here and there for cross-domain page in the iframe. And then there is this design philosophy (it seems) that opera refuses to endose printing iframe content directly from the parent window. I say design philosopy because I think they know that issue long before v9.

Modulo cross-domain restriction, this is an attempt for the cross-browser implementation.
[tt]
function print_ifrmae(s) {
[blue]//s being iframe's _name_, generally distinct from the id.[/blue]
var obj=window.frames;
if (navigator.userAgent.indexOf("Opera")!=-1) {
var owin=window.open(obj.location);
owin.opener.focus(); //lose its focus(): it matters
owin.print();
owin.close();
owin=null;
} else {
obj.focus(); //get its focus(): it matters
obj.print();
}
}[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top