View Full Version : Help with print
caliabris
09-22-2002, 04:38 PM
I need to print some pages from current
i have a search script
for exp: user need to print second and fourth page only ,from this search, from the current (first) page
I want he will click 'PRINT ME' and these pages will be delivered to the printer,without entering every page and clicking 'print'
Thank You
COBOLdinosaur
09-22-2002, 05:37 PM
You put each page in a wrap around div and then send it to a print window:
<html>
<head>
<title>Untitled</title>
<script>
function printIt(target) {
winId=window.open('','printwin','width=200,height=300');
winId.document.write(target);
winId.document.close();
winId.focus();
if (window.print) winId.print();
}
</script>
</head>
<body>
<div id="page1">
All the content of the page goes here
<a href="JavaScript:'"
onClick="printIt(document.getElementById('page1').innerHTML);return false">
print this page
</a></div>
<div id="page2">
All the content of the second page goes here>
<a href="JavaScript:'"
onClick="printIt(document.getElementById('page2').innerHTML);return false">
print this page
</a></div>
</body>
</html>
If you want them to be able to select multiple pages, then declare a global variable to haold the collection: var str='';
Then give them a build function to add pages:
function buildIt(target) {str+=target}
When the are ready to print it give them a ink like this:
<a href="JavaScript:;" onClick="printIt(str); return false"> send to printer</a>
If you want to do it cross page you are out of luck unless all page are from teh same domain, then you can open the daetail pages in a popup, a refer back to the str var in the parent.
Cross-domain forget it; you run into security limitations.
caliabris
09-22-2002, 05:42 PM
Thank you very much !
Hope it will work
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.