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 Mike Lewis 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 using Javascript

Status
Not open for further replies.

Chelsea7

Programmer
Aug 25, 2008
69
US
Hello everyone,

I have a question about printing a frame using Javascript.

I have a link on the menu.html page at the top frame which will print another page in another frame. I know that I could use something like;

<frame src="frame-left.htm" name="frame1">

However, I have different pages for that frame. These are different articles that have various webpage file names. I would like to know if there's anyway to print pages in the main frame regardless of the page name and prints anything in the main frame?

I've been looking around and I can only find the example above.

Any assistance will be appreciated.
 
From which frame are you wanting to issue the print command? If it is from within 'frame1', then you would use simply:

Code:
window.print();

If it from within the frameset definition itself, you might use something like:

Code:
window.frames['frame1'].print();

And from any arbitrary frame, you might use something like:

Code:
top.frames['frame1'].print();

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top