Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Location
    Graz (Austria)
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    print non visible page/file

    Hi guys,

    question: is it possible to print a certain file via javascript. the user pushes a button or link and than a file (htlm) will be printed, but not that file the user sees in the browser??

    thanx for replies


    foss

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    paris, france
    Posts
    1,216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i havent ever used the print command and i dont really know how much of a timeout it has but what you could do is make the html page with this script in it

    <script>
    function print_the_page()
    {
    document.print() //or whatever it is
    setTimeout("window.close()",10000)
    }
    </script>

    <body onload="print_the_page()">

    this script will print the page when loaded and then close itself after 10 seconds. you can change that to whetever you wan tbut maybe somecomputers wront have time to get the document to the printer before it closes. but i dont really know about that
    photoshop too expensive? use the GIMP! www.gimp.org

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    printing a hiddden frame

    I also know nothing about the print function, but I know how you can make a page users cannot see and have access to it. It involves frames, where one is 100 percent visible and the other is 0 percent visible. Just access the invisible frame using the parent object and have it print using whatever print functions are available.

    <html>
    <head>
    <title>My title</title>
    <script language="JavaScript">
    <!--
    function execPrint () {
    parent.frames[1].document.print();
    // where print() or whatever the official
    // print method is for that object and browser is.
    }
    // -->
    </script>
    </head>

    <frameset rows="100%,0">
    <frame src="what_user_sees.html">
    <frame src="hidden_page_to_print.html">
    </frameset>

    </html>

    obviously, that what_user_sees.html page has to contain some way of accessing the frameset page's execPrint() function. This can be done by

    <input type="button" value="print" onClick="parent.execPrint()">

    Does that make sense? Good luck!
    If at first you don't succeed, spend more time online researching javascript!
    Beck

  • #4
    New to the CF scene
    Join Date
    Jun 2002
    Location
    Graz (Austria)
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanx

    thanks to you!

    the idea with the frames isn't that bad!

    My question was posted, 'cause i search for a way to switch between the monitor-version of a page (black background and gray text) an the print version of the same text (white background and black text). But for this i have to go to the "Post/ request" area.

    Thanks for your answers

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    This will work in IE:

    <link rel=alternate media=print href="nicelyFormated.doc">

    This way when they press print it will actually get a word doc or .pdf or diferent page to print then the one they are viewing.

    You can read more about it:

    http://www.dynamicdrive.com/dynamici...printstyle.htm

  • #6
    New to the CF scene
    Join Date
    Jun 2002
    Location
    Graz (Austria)
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb ah !!

    Thank you John!

    I missed the article in the user preference area.

    I'll take this for the IE-Version of my page.
    For the NN-version i take the frameset solution.

    C U

  • #7
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi Guys,
    Hopefully, yall still remember this topic...

    I need to be able to let a user print documents like word or pdf and the frames dont seem to work. For example, I would have an html form with checkboxes that lists files in a folder held on a server (i have this made). When the user clicks the print button it will print out those files. Do you guys think this is possible?

    Thanks a lot for the help!!

  • #8
    Regular Coder
    Join Date
    Mar 2009
    Location
    Portland Oregon
    Posts
    690
    Thanks
    44
    Thanked 63 Times in 62 Posts
    Can I see the script? I hadn't even used a computer ever when this thread was created. hahaha. I have a lot of catching up to do.

    I would imagine you could make the pages in their own iframe and keep it hidden or off screen, then switch it to visible, give it the print command, and then set it back to hidden. Or, I wonder if it would print while it's hidden?

    Interesting. I can't wait to see what these guys think


  •  

    Posting Permissions

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