Forum Moderators: open

Message Too Old, No Replies

Print this article option

how does it work?

         

contentmaster

6:34 am on Apr 21, 2005 (gmt 0)

10+ Year Member



I have noticed a link on a number of sites which says "print this article". Once i click the link, my printer dialog box opens.

MY QUESTION: How does this work....is there a javascript code that makes it work?

orion_rus

9:58 am on Apr 21, 2005 (gmt 0)

10+ Year Member



If you have javascript enabled make simple img and onclick event like:
<img src='print.jpg' onclick=window.print() />

to ensure if user enables javascript you can use this:
<script>
documet.write("<img src='print.jpg' onclick=window.print() />");
</script>
and if users javascript enabled img would be shown and user can prints the page
Good luck to you!

contentmaster

12:50 pm on Apr 21, 2005 (gmt 0)

10+ Year Member



I used the first script and it worked thanks!

What about the second one? is that for people who do not have javascript enabled?

tomda

1:24 pm on Apr 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, in the second case, only the person having js enable will see the image and will be able to print the page.

Rambo Tribble

2:55 pm on Apr 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can modify the markup and script to display a print link or button if JavaScript is enabled. Otherwise, the user will have to use their browser's print button. You can format and control the parts of the page which print with CSS @media rules.