SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot pooney's Avatar
    Join Date
    Jan 2006
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is it possible to print a specific div?

    Is it possible? I would like to create some sort of hyperlink to print a div by ID, for example <div id="printme">Text to print</div>, and a button like <a href="#printme" onclick="print div!">Print this text</a>.

    Would javascript be the best way to do this?
    Web Host Advice - Under Development

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The best way is to probably have those links go to a server-side script which outputs a webpage containing only whatever was in that div. Anything else isn't going to be reliable if possible at all.

  3. #3
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,115
    Mentioned
    28 Post(s)
    Tagged
    2 Thread(s)
    You could use an alternate stylesheet that grabs all the other id's and..
    Code:
    #unwanted_for_print, #other_unwanted_div {
      display: none;
    }
    Use javascript to switch the stylesheets.


Bookmarks

Posting Permissions

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