SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    ********* Addict jaiem's Avatar
    Join Date
    Dec 2000
    Location
    New York, USA
    Posts
    1,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there anyway using HTML or some simple JavaScript to put a button or link (button is better) that will automatically print the current page? Or at least open the PRINT window in the visitor's browser?

    Thanks.
    Ocean View Host - Affordable web hosting plans for any business.
    Modern Technology, Old Fashioned Value & Service!
    U.S. Merchant Services - Reliable merchant account services for all business!
    Quality People Providing A Quality Service!

  2. #2
    The Hiding One lynlimz's Avatar
    Join Date
    Jul 2000
    Location
    Singapore
    Posts
    2,103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
    -- Albert Einstein

  3. #3
    I'm baaaaaaaaaaaaack! Fluffykins's Avatar
    Join Date
    Aug 2000
    Location
    Manchester, UK
    Posts
    1,046
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or use this clever little snippet of code:

    Code:
    <input type="button" value="Print" name="Button" onClick="window.print();return false">
    That renders a button, if you'd like to have a text link, or image link print the page, enclose it in a hyperlink like this:

    Code:
    <a href="#" onClick="window.print();return false">text or image</a>
    Ady
    v-technologies - Freelance Goodness.

  4. #4
    ********* Addict jaiem's Avatar
    Join Date
    Dec 2000
    Location
    New York, USA
    Posts
    1,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!!
    Ocean View Host - Affordable web hosting plans for any business.
    Modern Technology, Old Fashioned Value & Service!
    U.S. Merchant Services - Reliable merchant account services for all business!
    Quality People Providing A Quality Service!

  5. #5
    Technically, a bit dim macdan's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Flufffykins, I'm also looking to set this function up, does your solution work across browsers and on Macs? Also what does the # stand for (in the href="#")?

    Thanks for any help
    gorillaweb is a small London based digital design agency.

  6. #6
    I'm baaaaaaaaaaaaack! Fluffykins's Avatar
    Join Date
    Aug 2000
    Location
    Manchester, UK
    Posts
    1,046
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi macdan.

    The script I've used does work in IE 4+ and Netscape 4+ on a PC, but I've never tried it on a Mac so couldn't tell you about that one.

    The # in the hyperlink simply makes an empty hyperlink. We can't have a hyperlink that doesn't point somewhere, but seeing as the link only serves to call some JavaScript to print the page out there's no point pointing it to another website or HTML page. Of course if we don't use an a href="#" we can't click on the text, so we need it to make a dummy link.

    Hope that makes some sort of sense!

    Ady
    v-technologies - Freelance Goodness.

  7. #7
    Technically, a bit dim macdan's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Ady, I'll give it a whirl and see what happens!
    gorillaweb is a small London based digital design agency.


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
  •