Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 28th, 2005, 05:44 PM
Friend of Wrox
Join Date: Jun 2004
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to print contents of IFrame when is it a frams

I'm wondering what is wrong with my code. I've alrady used this function in an other application and it worked fine! The only difference with this new page is that he contents of the IFRAME is a frameset.

How can I have a button on my main page (calling to print the contents of the IFRAME which as stipulated above is a frameset) ?

Once again
Thanks for all your help,


Old March 29th, 2005, 09:46 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

I've never tried to do this. Normally you need to focus on the iframe before calling the print function. I don't know if you can with this scenario.
var oFrame = window.frames["<iframeNameToPrint>"];

Joe (Microsoft MVP - XML)
Old March 29th, 2005, 10:45 AM
Friend of Wrox
Join Date: Jun 2004
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks Joe, But I believe I've already scripted the focus correctly. I worked for a moment ... sort of: It had printed the top frame of the frameset inside that IFRAME. But as you can read, it only did it once :-(

Here's the code:


function myprint() {


.....And the IFRAME containing the Frameset:


<div id="CONTENT" style="position:relative; width:570px; height:475px; z-index:1; left: 192px; top: 20px;">

<iframe name="newsletter" src="newsletter.htm" width="570px" height="475px"></iframe>



Does anyone know how to do this?

Old March 29th, 2005, 10:47 AM
Friend of Wrox
Join Date: Jun 2004
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts

thought I might add the actual frameset (newsletter.htm) code too: Maybe I need to reference each frame, too, somehow?


<frameset rows="140,*" frameborder="NO" border="0" framespacing="0">
  <frame src="news_header.htm" name="top" scrolling="NO" noresize >
  <frame src="news.htm" name="main" scrolling="Auto">


Similar Threads
Thread Thread Starter Forum Replies Last Post
values from one iframe to another iframe URGENT raaj Beginning PHP 2 February 27th, 2007 12:19 PM
to print datagrid contents josna VB.NET 6 January 13th, 2006 12:02 AM
changing two frams at the same time in NS nightshonour Javascript How-To 1 May 3rd, 2005 07:28 PM
how to print the contents of datagrid using vb.net kumarkaushal VB.NET 2002/2003 Basics 1 March 21st, 2005 01:15 AM
how can I refresh the contents of an iframe? nerssi Javascript How-To 2 November 4th, 2004 06:05 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.