Welcome Guest, Not a member yet? Register   Sign In
Putting a Printer Icon on a Web Page?
#1

[eluser]Vik[/eluser]
I'd like to put a printer icon on the pages of my site, which, when clicked, would do the same thing that would happened if the user clicked "Print" normally on his or her computer (Mac or Windows). What is the correct way to do this?

Thanks in advance to all for any info.
#2

[eluser]richthegeek[/eluser]
the answer is Javascript, I think its something like:
Code:
[removed]document.print();
as the href of an A tag (cant put full code cos of censoring!)

Of course, if that doesnt work, try google.
#3

[eluser]richthegeek[/eluser]
ok bloody censoring Angry

going into bloody RAGE right now...

[removed] is "j_a_v_a_s_c_r_i_p_t_:" minus the underscores...
#4

[eluser]slowgary[/eluser]
Just do this:

Code:
<a ref='#' click='window.print()'><img src='print_icon.png'/></a>

but change 'ref' to 'href' and 'click' to 'onclick'
#5

[eluser]TheFuzzy0ne[/eluser]
Just for the record, you can replace, say the "j" in javascript: with &amp;#106;

Code:
javascript:document.print();

EDIT: Or not... Doesn't seem to work in code tags...

javascript:document.print();
#6

[eluser]Vik[/eluser]
Great. Thanks very much, guys!
#7

[eluser]drewbee[/eluser]
[quote author="TheFuzzy0ne" date="1238452654"]Just for the record, you can replace, say the "j" in javascript: with &amp;#106;

Code:
javascript:document.print();

EDIT: Or not... Doesn't seem to work in code tags...

javascript:document.print();[/quote]

This is what I hate about CI's filtering. I disabled it.

If you look in the code it preserves and relabels any ambersand, then reconverts it back afterwords.

In a webpage if I typed < i would expect to see < on the display.
If i typed &__lt; I would expect &__lt; to appear, not < (obviously i inserted a hypen to keep it from being converted.... argh CI... this is one of my biggest querks that I really do not see the point behind. I have disabled most of CI's uneeded 'filtering' as it doesn't act in a standard behavior.

I ran my new code against all scripts at http://ha.ckers.org/xssAttacks.xml all attempt types in a form, outside of a form, and after form submission and all was well.

So once again... why?




Theme © iAndrew 2016 - Forum software by © MyBB