473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

print using frames

how do I create a print button that is on my index page that prints my
target page (and only the target page)

I tried
<INPUT onclick=window. print(); type=button value="Print This Page"
style="font-size: 10px; float:right">

But it prints the index page.

Thank you.
Jan 26 '07 #1
2 2809

Hello,

Here is a solution:

Code for your index page:
--------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitl ed Document</title>
</head>
<body>
<h2>Index page</h2>
<script>
function printMyOtherPag e() {
// It is forbidden to change the iframe src so we submit a form into
it
// with the desired page as the action.
// We also add a parameter PRINT_ME so that the page can detect that
it
// has to print herself.
document.PRINTE R.action = document.PRINTE R.PAGE_TO_PRINT .value;
document.PRINTE R.submit();
}
</script>
<form name="PRINTER" target="printed Frame" action="">
<input type="hidden" name="PRINT_ME" >
The page you want to print <input name="PAGE_TO_P RINT" type="text"
value="page1.ht m">
<input type="button" onClick="printM yOtherPage();" value="Print it">
</form>
<iframe name="printedFr ame" src="dummy.htm"
style="visibili ty:hidden"></iframe>
</body>
</html>

Code of the page you want to print from the index page, ex apge1.htm
(you just need to copy the Onload attribute in the desired pages):
------------------------------------------------------------------------------------------------------------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitl ed Document</title>
</head>
<body onLoad="if (location.href. indexOf('PRINT_ ME') != -1)
window.print(); ">
page1
</body>
</html>

Hopes it will help you.

Olivier

On Jan 26, 5:18 am, "prophet" <M_Mo...@hotmai l.comwrote:
how do I create a print button that is on my index page that prints my
target page (and only the target page)

I tried
<INPUT onclick=window. print(); type=button value="Print This Page"
style="font-size: 10px; float:right">

But it prints the index page.

Thank you.
Jan 26 '07 #2
prophet said the following on 1/25/2007 11:18 PM:
how do I create a print button that is on my index page that prints my
target page (and only the target page)

I tried
<INPUT onclick=window. print(); type=button value="Print This Page"
style="font-size: 10px; float:right">

But it prints the index page.
You could try reading the group FAQ, specifically section 4.11

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9419
by: Marcus Bjorke | last post by:
I use a print link that causes a problem with Opera 7. The link looks like this <a href="javascript:parent.frames.mainFrame.print()">Print this page</a> I also used <a href="javascript:print()">Print this page</a> and it also worked with most browsers. I realize that it only works if you have Microsoft Windows versions for PC but that is...
4
6235
by: Scott Navarre | last post by:
Hello, I have 2 frames. The top one is the control frame and the bottom one is the display. I have a roll-over button in the top frame that I want to use to do a print() for the bottom frame. I tried having this JavaScript code when the roll-over button is clicked: parent.frames.focus();parent.frames.print() I am using Internet...
2
2062
by: Balamurali C | last post by:
Hi All I'm having one problem, since im debuging this last one week I'm not able to do. Problem: In my webage I have two Frames(top & bottom) in the top frame I'm displaying some images(logo...etc) and bottom frame I'm displaying some document(excel,word,ppt,pdf etc...)which are working fine. when I take print, using IE-File-menu...
9
2723
by: Scott M | last post by:
I'm printing a directory of about 500 multi-page tifs to a high speed printer and the spooler process is killing me!!! here is a little code..... Public Function PrintImage(ByVal SourceFile As String) As Boolean Try
5
6446
by: Raman | last post by:
Hello friends, I want to print an ID card. I have one Windows Form that contains front and back side. The printer is printing both front and back side at a time. I am trying to send both sides at a time. But it is printing front side on one card and back side on second card. I want to print both sides in a same card.
2
6820
by: zlarson | last post by:
I have a website where a div's innerHTML is replaced with a string: <input type="button" name="myButton" id="myButton" onClick="printReport();"><IFRAME name="myFrame" id="myFrame"></IFRAME> which holds a report. when the button is clicked it calls a function to print the IFRAME: function printReport() {...
8
4055
by: makunag | last post by:
Didn't get answer with google and in my regular forum. Came across this site and posting here. Your help will be highly appreciated ! Our application have frames - MainNav, TaskNave and Content. When print button is clicked, it prints only the Content (obviously top.Content.focus() is in the code before window.print()). We were using windows...
2
1707
by: John Kotuby | last post by:
Hi all, Again running into problems converting existing ASP to ASP.NET 2 in VB. I am simply trying to print a portion of the HTML displayed on-screen and not the entire document. Specifically I just want to print the HTML contained in the content area of my Masterpage layout, without the user having to click File/Print in the browser. I...
1
1167
by: gangui | last post by:
Hello, I need to print two frames in two sheets through javascript. I've tried to : function print() { top.window.focus();
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.