Print web page ?

Discussion in 'HTML' started by RAYMOND PISTEY, May 3, 2010.

  1. Hello on my site this is what is happenning

    Part 1 - This is what works and prints me output I like from <print> link in
    body section

    <head>
    <script type="text/javascript">
    function ClickHereToPrint(){
    try{
    var oIframe = document.getElementById('ifrmPrint');
    var oContent = document.getElementById('divToPrint').innerHTML;
    var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
    if (oDoc.document) oDoc = oDoc.document;
    oDoc.write("<html><head><title>title</title>");
    oDoc.write("</head><body onload='this.focus(); this.print();'>");
    oDoc.write(oContent + "</body></html>");
    oDoc.close();
    }
    catch(e){
    self.print();
    }
    }
    </script>
    </head>


    <body>

    <a onclick="ClickHereToPrint();">Print</a>

    <iframe id='ifrmPrint' src='#' style="width:0px; height:0px;"></iframe>


    <div id="divToPrint">
    content
    </div>
    </body>

    PART 2 - How do I change the file, print menu item to use my part 1 code

    window.print?

    Thanks

    Ray
    RAYMOND PISTEY, May 3, 2010
    #1
    1. Advertising

  2. RAYMOND PISTEY wrote:

    > Hello on my site this is what is happenning


    This seems to relate to your previous message "button from this code", with
    no reference to it.

    > Part 1 - This is what works and prints me output I like from <print>
    > link in body section


    You still don't specify a URL or tell what you are actually trying to
    accomplish.

    > <iframe id='ifrmPrint' src='#' style="width:0px;
    > height:0px;"></iframe>


    It looks like you are trying to create problems, instead of solving any. You
    can disprove this impression by providing a URL and an understandable
    explanation of what you are trying to do (instead of fragments of code
    supposed to solve an unspecified problem).

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, May 3, 2010
    #2
    1. Advertising

  3. RAYMOND PISTEY

    cwdjrxyz Guest

    On May 2, 7:05 pm, "RAYMOND PISTEY" <> wrote:
    > Hello on my site this is what is happenning
    >
    > Part 1 - This is what works and prints me output I like from <print> link in
    > body section
    >
    > <head>
    > <script type="text/javascript">
    > function ClickHereToPrint(){
    >     try{
    >         var oIframe = document.getElementById('ifrmPrint');
    >         var oContent = document.getElementById('divToPrint').innerHTML;
    >         var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
    >         if (oDoc.document) oDoc = oDoc.document;
    >   oDoc.write("<html><head><title>title</title>");
    >   oDoc.write("</head><body onload='this.focus(); this.print();'>");
    >   oDoc.write(oContent + "</body></html>");
    >   oDoc.close();
    >     }
    >     catch(e){
    >      self.print();
    >     }}
    >
    > </script>
    > </head>
    >
    > <body>
    >
    > <a onclick="ClickHereToPrint();">Print</a>
    >
    >  <iframe id='ifrmPrint' src='#' style="width:0px; height:0px;"></iframe>
    >
    > <div id="divToPrint">
    >   content
    >  </div>
    > </body>
    >
    > PART 2 -  How do I change the file, print menu item to use my part 1 code
    >
    > window.print?


    Someone will be better able to help if you give the url for a complete
    working example without the button. However I will point out that you
    are using javascript, and thus your print link will not work for
    browsers that have script turned off. See http://www.w3schools.com/browsers/browsers_stats.asp
    near the bottom of the page. At one time many turned their script off,
    but perhaps only about 5% of visitors to the w3schools site now do.
    This may or may not be typical of other sites. In some cases one can
    use server side scripting, such as php, to avoid this problem. Also
    you might use a no script path that gives text instructions for
    printing if there is not script support.
    cwdjrxyz, May 3, 2010
    #3
  4. Fixed it using the browser print, by placing div where i wanted, sorry
    newbie here

    "cwdjrxyz" <> wrote in message
    news:...
    On May 2, 7:05 pm, "RAYMOND PISTEY" <> wrote:
    > Hello on my site this is what is happenning
    >
    > Part 1 - This is what works and prints me output I like from <print> link
    > in
    > body section
    >
    > <head>
    > <script type="text/javascript">
    > function ClickHereToPrint(){
    > try{
    > var oIframe = document.getElementById('ifrmPrint');
    > var oContent = document.getElementById('divToPrint').innerHTML;
    > var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
    > if (oDoc.document) oDoc = oDoc.document;
    > oDoc.write("<html><head><title>title</title>");
    > oDoc.write("</head><body onload='this.focus(); this.print();'>");
    > oDoc.write(oContent + "</body></html>");
    > oDoc.close();
    > }
    > catch(e){
    > self.print();
    > }}
    >
    > </script>
    > </head>
    >
    > <body>
    >
    > <a onclick="ClickHereToPrint();">Print</a>
    >
    > <iframe id='ifrmPrint' src='#' style="width:0px; height:0px;"></iframe>
    >
    > <div id="divToPrint">
    > content
    > </div>
    > </body>
    >
    > PART 2 - How do I change the file, print menu item to use my part 1 code
    >
    > window.print?


    Someone will be better able to help if you give the url for a complete
    working example without the button. However I will point out that you
    are using javascript, and thus your print link will not work for
    browsers that have script turned off. See
    http://www.w3schools.com/browsers/browsers_stats.asp
    near the bottom of the page. At one time many turned their script off,
    but perhaps only about 5% of visitors to the w3schools site now do.
    This may or may not be typical of other sites. In some cases one can
    use server side scripting, such as php, to avoid this problem. Also
    you might use a no script path that gives text instructions for
    printing if there is not script support.
    RAYMOND PISTEY, May 4, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bernard Segonnes

    Print and print overview and current page

    Bernard Segonnes, Nov 4, 2004, in forum: Java
    Replies:
    0
    Views:
    444
    Bernard Segonnes
    Nov 4, 2004
  2. Sam
    Replies:
    1
    Views:
    645
    seigo
    Nov 10, 2006
  3. Ben
    Replies:
    5
    Views:
    5,264
  4. keto
    Replies:
    0
    Views:
    905
  5. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    337
    David Cournapeau
    Dec 30, 2008
Loading...

Share This Page