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.