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.