473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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 2785

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>Untitled Document</title>
</head>
<body>
<h2>Index page</h2>
<script>
function printMyOtherPage() {
// 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.PRINTER.action = document.PRINTER.PAGE_TO_PRINT.value;
document.PRINTER.submit();
}
</script>
<form name="PRINTER" target="printedFrame" action="">
<input type="hidden" name="PRINT_ME">
The page you want to print <input name="PAGE_TO_PRINT" type="text"
value="page1.htm">
<input type="button" onClick="printMyOtherPage();" value="Print it">
</form>
<iframe name="printedFrame" src="dummy.htm"
style="visibility: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>Untitled 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...@hotmail.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.javascript 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
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...
4
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....
2
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...
9
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...
5
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...
2
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...
8
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....
2
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...
1
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.