javascript:print (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


Josh22in03 -> javascript:print (5/5/2003 14:25:55)

Does anybody know the javascript code for making a line of text link to print the document? I cant think of it off the top of my head. I think its javascript:print() or something like that. Thanks!!!




Gil -> RE: javascript:print (5/5/2003 14:56:15)

There' s a few[:)] ways - here' s a simple one:

<!--

var message = " Print this Page" ;

function printpage() {
window.print();
}

document.write(" <form><input type=button "
+" value=\" " +message+" \" onClick=\" printpage()\" ></form>" );

//-->
</script>




Josh22in03 -> RE: javascript:print (5/5/2003 14:57:58)

and put that were in the document? right next to the link??

thanks




Gil -> RE: javascript:print (5/5/2003 15:10:55)

quote:

and put that were in the document?
Put it where you want the button. What link? That includes a Print this Page button




pageoneresults -> RE: javascript:print (5/5/2003 22:56:38)

And here is a little shorter version that may be a little easier to work with...

<a title=" Print this page" href=" #" onClick=" window.print()" >Print this page</a>




Josh22in03 -> RE: javascript:print (5/6/2003 9:50:09)

now if I usw that method, can I have it link to a little printer icon instead of the text?

quote:

<a title=" Print this page" href=" #" onClick=" window.print()" >Print this page</a>


I am asuming that insread of the text Print this page, I can put <img src=" print.ico> and then the text or something like that

Thanks again




abbeyvet -> RE: javascript:print (5/6/2003 10:05:53)

Correct - just put the image in instead of or as well as the text.

There is a page with lots of thses short snippets of JavaScript here:

http://www.outfront.net/tutorials_02/adv_tech/js_snippets.htm#print




Josh22in03 -> RE: javascript:print (5/6/2003 10:07:57)

Cool. Thanks. Ill have to check out that site!




Josh22in03 -> RE: javascript:print (5/6/2003 10:40:39)

Ok so I have this code

quote:

a title=" Print this page" href=" #" onClick=" window.print()" >Print this page</a>


Now if I want to add a picture to this would I make it look like this:

<a title=" Print this page" href=" #" onClick=" window.print()" ><img src=" images/print.gif" >Print this page<a/> ??

I tried this way, and it messed up the whole page. Thanks again.




Gil -> RE: javascript:print (5/6/2003 10:58:07)

What do you mean by " it messed up the whole page" ?

I wouldn' t think you' d need both the text link and a graphic link?

Why not: <a title=" Print this page" href=" #" onClick=" window.print()" ><img src=" images/print.gif" ><a/>




Josh22in03 -> RE: javascript:print (5/6/2003 11:31:58)

quote:

What do you mean by " it messed up the whole page" ?


What I mean is it threw the text and allingment off on the top of the page.

quote:

<a title=" Print this page" href=" #" onClick=" window.print()" ><img src=" images/print.gif" ><a/>


That is the code I put in and the pcture didn' t show up!




abbeyvet -> RE: javascript:print (5/6/2003 11:36:31)

Do you have a directory called images in the same directory as that page?

Is there an image called print.gif in that directory?

If the path is correct there is no reason for that not to work.

A URL would probably help at this stage.


Oops- just noticed something!

quote:

<a title=" Print this page" href=" #" onClick=" window.print()" ><img src=" images/print.gif" >Print this page<a/>


I think <a/> should be </a> [:D]




Josh22in03 -> RE: javascript:print (5/6/2003 11:38:42)

Yeah the print.gif was in the images directory and I got the horrible red x of death. I took the image out of the images folder and just put it into the root web. Same thing. I dont have a url right now. Its not published. But let me see what I can do.

thanks

As for your <a/> instead of </a> that was correct. THe print feature worked. Just not the image





Josh22in03 -> RE: javascript:print (5/6/2003 11:50:07)

Ok I think I got it. I just found the picture and inserted it into FP and here was the link

<img border=" 0" src=" file://Ywire-server/public/Josh/Sites/myweb/print.gif" width=" 22" height=" 20" >

thats what I needed for it to show up..




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
6.347656E-02