Web Analytics Made Easy -
StatCounter print non visible page/file - CodingForum

Announcement

Collapse
No announcement yet.

print non visible page/file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment


        • #5
          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:

          Comment


          • #6
            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

            Comment


            • #7
              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!!

              Comment


              • #8
                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

                Comment

                Working...
                X