SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    do righteous deeds
    Join Date
    Aug 2006
    Location
    Türkiye Turkey تركيى
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can I print the form, before I send it?

    I want to print a parf of document. I expect, you write a code.
    Last edited by muazzez; Jan 8, 2007 at 06:05.

  2. #2
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't really just print part of a document - the best you can do is set 'display: none' in your print stylesheet for those sections of the page you don't want to print, or popup a new window just containing the sections you need, then print that window.

    More importantly, you can't force the user to print the document; all you can do is open the print dialog, whether they choose to print it or not is up to them.

  3. #3
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Buddy Bradley View Post
    You can't really just print part of a document.
    Sorry in first sentence is something else then in the rest of post. Of course you can print part of document, because you can switch stylesheets also for print. Try this

    Code:
    <link rel="stylesheet" type="text/css" media="screen,projection" href="styl1.css" />
    <link rel="stylesheet" type="text/css" media="print" href="print1.css" />
    <link rel="stylesheet" type="text/css" media="print" href="print2.css" />
    <title>Title</title>
    
    <script type="text/javascript">
    <!--
    function printOne(article){
    if (!document.getElementsByTagName) return;
    var el=document.getElementsByTagName("link");
    for (var i=0;i<el.length;i++){
    if (el[i].getAttribute("rel").indexOf("style")!=-1 && el[i].getAttribute("media")=="print"){
    el[i].setAttribute("href",article+'.css')
    }}}
    //-->
    </script>
    </head>
    <body>
    
    <p class="article1">lorem ipsum</p>
    
    <p class="article2">oposum dolor</p>
    <p class="noprint"><a href="javascript:printOne('print1')">print 1</a>
    <a href="javascript:printOne('print2')">print 2</a></p>
    in stylesheets just display block/none .article1, .article2


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
  •