04/05/2006, 18:35
|
| | Fecha de Ingreso: diciembre-2004
Mensajes: 413
Antigüedad: 19 años, 11 meses Puntos: 0 | |
disuclpa que lo postee en ingles , no tengo tiempo para traducir,
Suppose you have a page with an image such as a directions map on it. You want the reader to be able to click on the image to print a copy. You can start with the onclick event tied to the image element. It would call the window.print() method to do the actual printing of the page.
<img src="location.jpg" onclick="window.print();">
But what if you only want to print the image and not the rest of the page. This takes a bit more work but mostly a bit of thought. Since window.print() does a whole page, why not put a copy of the image on its own page. You can even scale the image, center it, and add information if needed. A fragment of the second page is:
<script type="text/javascript">
function doit() {
window.print();\\ does the print of this page
top.location.href='first.htm';} \\ returns to original page
</script></head><body onload="doit();">
The only additional component you need besides the two pages is a method of transferring from one to the other. Transferring to another page can be done by setting the top.location.href property
<img src="location.jpg" onclick="top.location.href='second.htm';"> |