SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up how to print the certain portion of a webpage ??

    Hello frens and seniors of Sitepoint...
    em back with some problem in javascript...
    what i am trying to do is to print the certain portion of the page (not the whole page) using javascript but i am not getting the appropriate soln..Can anybody help me with the neccessary js code...
    Anyway thanks in advance

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,032
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    printing page

    I don't know if using seperate "print" CSS would work for a javascript print()
    (try it and see). You may have to parse the page into a variable and then print that.

  3. #3
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    first of all Thanks for the reply
    i would be greatful if you help me with some codes...

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,032
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    print CSS

    I don't know how you have your CSS, but I use something like
    HTML Code:
    <link rel='stylesheet' type='text/css' href='./screen.css' media='screen' >
    <link rel='stylesheet' type='text/css' href='./print.css' media='print' >
    in the pages' head sections. A simple way to test if javascript prints the page or the screen would be to have some things with a style of display: none in the print CSS (eg. nav links). Then have your script print the page. If the things with display: none print, then the script is printing the screen and the solution will be more complex. If it doesn't print the display: none page elements, then you're all set. IMO having a seperate print CSS is a good idea anyway for users that may use their browser to print your pages. You can see examples of this at my site at www.mittineague.com if you do the menu "file -> print preview"

  5. #5
    SitePoint Zealot sajjad's Avatar
    Join Date
    May 2005
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello there

    use the :target pseudo-class to select anything that is the target
    of a URI. for example, you might use the following rules to hide all
    paragraphs except for the target one:

    @media print {
    p { display: none; }
    p:target { display: block; }
    }

    then, only the target paragraph would print.
    I don't think this is a part of CSS2, but mozilla seems to support it, and
    it is part of the CSS3 draft.

    http://www.w3.org/TR/2001/CR-css3-se...#target-pseudo


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
  •