Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts

    is there a way to print the content of a div?

    Hey,

    I have a page which contains driving directions to my lab at school. The directions are segmented by direction you are comming from (so 'From East, From West, Public Transportation, etc')

    What I want to do is provide a link so that users can print whichever directions they need without printing the whole page. Currently the different sections are seperated in divs with different ID's.

    Is there a way / is it simple to have a print button which would only print the content of 'div X'...

    alternatively, i suppose i could create little .htm files with the seperate directions in each and somehow call that print using something akin to window.print('fromEast.htm');

    any suggestions?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    728
    Thanks
    35
    Thanked 132 Times in 123 Posts
    You could use css-link a file that only prints your div:
    set the media attribute in the source to 'print'

    *{display:none}
    #nameofmyDiv{display:block}

  • #3
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    I suppose what I was trying to do is to avoid having the same text twice. if I can't then i will figure out an alternative.

    i dont suppose there's a js way to say "onclick, add this classname to the div containing this link" ... and that classname would set the media=print only

    or am i dreaming in technicolor?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •