SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, everyone. I am looking for a simple script to implement on my web site that will let users print my pages (without background colors, more readable, etc.) I am very fluent in scripting languages (ASP, JScript, VBScript, ADO, etc.), so implimentation shouldn't be a problem. Please post a response as this would be a great help to my web site. It would also be intriguiging to know how SitePoint does it themselves (for all you SitePoint Admins out there). Thanks!
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Goober,

    Since all of our content resides in a MySQL database, our printable article view is simply a different PHP script that formats the text of our articles appropriately. If you want to discuss this further, however, the conversation would best be moved to the server-side scripting forum.

    By looking for a client-side solution I think you'd be making a lot of extra work for yourself...
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    Ex-SitePointer silver trophy
    Patrick's Avatar
    Join Date
    Oct 2000
    Location
    Harbinger, NC, U.S.A.
    Posts
    4,126
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure if this is what you are talking about. But, I thought I would try.

    <b><font face="Verdana" size="1"><script language="JavaScript">

    if (window.print) {
    document.write ('<a class=side href="javascript:window.print();"><b><font face="Verdana" size="1">Print This Page</a></font></b></br>')
    }
    </script>
    </font></b>

    Good Luck.

  4. #4
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think he was referring to Printer-Friendly Versions of pages, and Kevin's right: it's a bit more complex that that.

    Quite simply, you want to have a page, say, "print.php" - on the link to view a printable version on your article page (let's say the URL of the article is "article.php?id=1") - you'd create a link within PHP like this:


    echo("<a href=\"print.php?id=$id\">View A Printable Version</a>");

    So, in this case, going to the article with an ID of "1" would produce a link leading to "print.php?id=1" - from then on, it's simple: you have the print.php page check for the variable "$id" - and if it exists, grab the corresponding record from whatever database you're using.

    Hope this helps.


  5. #5
    SitePoint Member
    Join Date
    Dec 2000
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Goober,

    This might help. There is an onbeforeprint and onafterprint event in javascript. Here is a url to a tutorial that will tell you how they work.

    http://www.wsabstract.com/javatutors/ie5print.shtml


  6. #6
    Not Bad, eh? Justin Sampson's Avatar
    Join Date
    Aug 2000
    Location
    N.S., Canada
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,
    Here's a simple way of doing what you want. On the page you want to print just link to this file. On each page you wan't to be printable just put <!-- body --> and <!-- /body --> around the content. The script then pulls the text and displays the content in anyway you want.

    <?php
    $lines_array = file("$HTTP_REFERER");

    $lines_string = implode('', $lines_array);

    eregi("<!-- body -->(.*)<!-- /body -->", $lines_string, $body);

    echo $body[0];
    ?>

  7. #7
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    Thanks, but my server does not support PHP, only ASP. Thanks! That leaves VBScript, JavaScript, etc.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)


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
  •