Hola, como puedo hacer un boton que mande a para imprimir un archivo, en este caso una imagen GIF desde mi pagina.
La mayoria que encontre solo imprimen la pagina que esta abierta en el momento, no algun otro archivo dentro dentro del sitio.
| |||
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';"> |