login about faq


I am making a site and have set a css sheet that is called when someone trys to print a page, I also have some javascript I want to run at the time when it is printed.

So my question to you is, how would I go about this?

Thanks

asked Dec 22 '10 at 09:36

DomChester's gravatar image

DomChester
391121625


Try the following line within the page you want the CSS applied to:

<link rel="stylesheet" type="text/css" media="print" href="print.css"/> Check this site out for some javascript print samples that might help you: http://www.javascriptkit.com/javatutors/ie5print.shtml

answered Dec 22 '10 at 12:39

David's gravatar image

David
3.3k112062

Thanks for that, however I am still a bit confused.

If I had a seperate javascript sheet called "footnoteLinks.js" I only want that to run when someone trys to print the page (when "print.css" is used)

what would I put in the main html page?

answered Dec 23 '10 at 05:40

DomChester's gravatar image

DomChester
391121625

1

If you want the js to run after the print selection you would use the onafterprint command. You can place it the head section of your page with the rest of your javascript.

(Dec 23 '10 at 09:33) David David's gravatar image

Thanks for that

(Dec 23 '10 at 11:08) DomChester DomChester's gravatar image

I myself am still learning js but I have to admit it is fun. Hopefully someone else will see your post and possibly offer a better or easier way to accomplish what you want. Good luck.

(Dec 23 '10 at 13:07) David David's gravatar image

are you using any websites to learn? as I am looking for some more online tutorials

(Dec 24 '10 at 02:42) DomChester DomChester's gravatar image

Yes I am. One of the sites is the above site for online javascript tutorials. There are several more online if you google for online coding tutorials or any variation of that. I could post them here but creates bad juju if the link is bad. If you like reading without the glare of the screen, go to Amazon and check out the books like CSS, The missing manual and Javascript, The missing manual. They're great books and I use them as desk refernces all the time. There are other books in the missing manual series for different languages such as HTML, PHP, etc.

(Dec 24 '10 at 09:41) David David's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported


Join Us in the Chat Room

Tags:

×142
×60
×39

Asked: Dec 22 '10 at 09:36

Seen: 1,407 times

Last updated: Dec 24 '10 at 09:43