Problem printing popup pages.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gb

    Problem printing popup pages.

    Hi All,

    Ive created a popup page using 'var openWindow = window.open("ne w","pop")'

    And added content using openWindow.docu ment.write(" "); statements. But now
    I would like to be able to print this page?

    openWindow.docu ment.write("<a href='#'
    onClick='self.c lose()'>Close<\/a><\/p>")

    This closes the page but these lines below only print the parent page not
    the popup child window.

    openWindow.docu ment.write("<a href='#'
    onClick='self.p rint()'>Print<\/a><\/p>")
    openWindow.docu ment.write("<a href='#'
    onClick='window .print()'>Print <\/a><\/p>")

    Ive also been trying to write a function based on document.lastCh ild:

    popupPrint()

    var popUp = document.lastCh ild;
    popUp.print();
    }

    But nothing works?

    Any help appressiated i'm using IE5.5 if this has an effect?

    Regards

    gb


  • Fabian

    #2
    Re: Problem printing popup pages.

    gb hu kiteb:
    [color=blue]
    > Hi All,
    >
    > Ive created a popup page using 'var openWindow =
    > window.open("ne w","pop")'
    >
    > And added content using openWindow.docu ment.write(" "); statements.
    > But now I would like to be able to print this page?[/color]

    Why do you even assume that the machine viewing your web page has a
    printer attached?


    --
    --
    Fabian
    Visit my website often and for long periods!


    Comment

    • Lee Mundie

      #3
      Re: Problem printing popup pages.

      <a href="javascrip t:onClick=windo w.print()">prin t</a> should work.

      Regards
      Lee

      "gb" <gb@tinyworld.c o.uk> wrote in message
      news:3fbfd7b0_2 @mk-nntp-2.news.uk.tisca li.com...[color=blue]
      > Hi All,
      >
      > Ive created a popup page using 'var openWindow =[/color]
      window.open("ne w","pop")'[color=blue]
      >
      > And added content using openWindow.docu ment.write(" "); statements. But[/color]
      now[color=blue]
      > I would like to be able to print this page?
      >
      > openWindow.docu ment.write("<a href='#'
      > onClick='self.c lose()'>Close<\/a><\/p>")
      >
      > This closes the page but these lines below only print the parent page not
      > the popup child window.
      >
      > openWindow.docu ment.write("<a href='#'
      > onClick='self.p rint()'>Print<\/a><\/p>")
      > openWindow.docu ment.write("<a href='#'
      > onClick='window .print()'>Print <\/a><\/p>")
      >
      > Ive also been trying to write a function based on document.lastCh ild:
      >
      > popupPrint()
      >
      > var popUp = document.lastCh ild;
      > popUp.print();
      > }
      >
      > But nothing works?
      >
      > Any help appressiated i'm using IE5.5 if this has an effect?
      >
      > Regards
      >
      > gb
      >
      >[/color]


      Comment

      • Lee Mundie

        #4
        Re: Problem printing popup pages.

        Hmmm, didn't think that was fair... 3 x three worded reasons:

        User enhanced experience
        Useability and accessibility
        Human Centered Interfaces...

        Should always assume that a person has peripherals attached and design to
        cover... a printer being the most basic and common.

        Regards

        Lee


        "Fabian" <lajzar@hotmail .com> wrote in message
        news:bponah$1q9 db4$2@ID-174912.news.uni-berlin.de...[color=blue]
        > gb hu kiteb:
        >[color=green]
        > > Hi All,
        > >
        > > Ive created a popup page using 'var openWindow =
        > > window.open("ne w","pop")'
        > >
        > > And added content using openWindow.docu ment.write(" "); statements.
        > > But now I would like to be able to print this page?[/color]
        >
        > Why do you even assume that the machine viewing your web page has a
        > printer attached?
        >
        >
        > --
        > --
        > Fabian
        > Visit my website often and for long periods!
        > http://www.lajzar.co.uk
        >[/color]


        Comment

        • Lasse Reichstein Nielsen

          #5
          Re: Problem printing popup pages.

          "Lee Mundie" <lee.j.mundie@n tlworld.com> writes:

          Please don't top post.
          [color=blue]
          > <a href="javascrip t:onClick=windo w.print()">prin t</a> should work.[/color]

          The "onClick=" is not needed, and in fact does nothing except create
          a new global variable.

          You should not use javascript:-URLs. I recommend using a button
          <input type="button" value="Print!" onclick="window .print()">
          If you insist on using a link, give it a meaningful href, but use
          the onclick handler for Javascript:
          <a href="YouNeedJa vascript.html" onclick="window .print();return false;">
          Print!</a>

          (in "YouNeedJavascr ipt.html" you explain why your page only works well
          with Javascript enabled).

          Even if you write the a-element with Javascript, you should use the
          onclick attribute. It doesn't have the potential, often unexpected,
          side effects of javascript:-URLs (like clearing the page if the
          Javascript expression doesn't evaluate to undefined).

          /L
          --
          Lasse Reichstein Nielsen - lrn@hotpop.com
          DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
          'Faith without judgement merely degrades the spirit divine.'

          Comment

          • Michael Winter

            #6
            Re: Problem printing popup pages.

            Lee Mundie wrote on 22 Nov 2003:
            [color=blue]
            > Hmmm, didn't think that was fair... 3 x three worded reasons:
            >
            > User enhanced experience
            > Useability and accessibility
            > Human Centered Interfaces...
            >
            > Should always assume that a person has peripherals attached and
            > design to cover... a printer being the most basic and common.[/color]

            But in this case, you don't need to cover such a need. If a user
            wants to print a page, they can use their browser's 'Print' command.
            That's what it's there for and what I look for - not whether the
            author was "kind" enough to provide a button or link.

            Mike

            And don't top post.

            --
            Michael Winter
            M.Winter@blueyo nder.co.uk.invalid (remove ".invalid" to reply)

            Comment

            • Fabian

              #7
              Re: Problem printing popup pages.

              Lee Mundie hu kiteb:
              [color=blue]
              > Hmmm, didn't think that was fair... 3 x three worded reasons:
              >
              > User enhanced experience
              > Useability and accessibility
              > Human Centered Interfaces...
              >
              > Should always assume that a person has peripherals attached and
              > design to cover... a printer being the most basic and common.[/color]

              If someone has a printer, chances are they are able to print from the
              web browser just fine using the normal browser interface. Why reinvent
              something that already exists?

              And if the browser was such that printing was not possible even assuming
              a printer is attached, then surely javascript would also fail as a
              solution?

              I suppose the point is that you want to be able to print this window
              while still having the usual window interface hidden. This is one of the
              big reasons popup windows are hated - the interface is often hidden. But
              there is still control-P, or the best solution - no popups, or, if you
              must have popups, don't hide the interface.


              --
              --
              Fabian
              Visit my website often and for long periods!


              Comment

              • DU

                #8
                Re: Problem printing popup pages.

                Michael Winter wrote:
                [color=blue]
                > Lee Mundie wrote on 22 Nov 2003:
                >
                >[color=green]
                >>Hmmm, didn't think that was fair... 3 x three worded reasons:
                >>
                >>User enhanced experience
                >>Useability and accessibility
                >>Human Centered Interfaces...
                >>
                >>Should always assume that a person has peripherals attached and
                >>design to cover... a printer being the most basic and common.[/color]
                >
                >
                > But in this case, you don't need to cover such a need. If a user
                > wants to print a page, they can use their browser's 'Print' command.
                > That's what it's there for and what I look for - not whether the
                > author was "kind" enough to provide a button or link.
                >
                > Mike
                >
                > And don't top post.
                >[/color]

                I agree with the above. Nevertheless, there could be several reasons to
                create a custom stylesheet for printing.

                1- remove webpage background color
                2- display url values (hypertext links) and not text of links in the
                printed form
                3- control page break
                4- control font size

                So far, no one in this thread mentioned that.

                CSS Design: Going to Print
                Say no to “printer-friendly” versions and yes to printer-specific style sheets. CSS expert Eric Meyer shows how to conceive and design print style sheets that automatically format web c…


                DU


                Comment

                • DU

                  #9
                  Re: Problem printing popup pages.

                  Fabian wrote:
                  [color=blue]
                  > Lee Mundie hu kiteb:
                  >
                  >[color=green]
                  >>Hmmm, didn't think that was fair... 3 x three worded reasons:
                  >>
                  >>User enhanced experience
                  >>Useability and accessibility
                  >>Human Centered Interfaces...
                  >>
                  >>Should always assume that a person has peripherals attached and
                  >>design to cover... a printer being the most basic and common.[/color]
                  >
                  >
                  > If someone has a printer, chances are they are able to print from the
                  > web browser just fine using the normal browser interface. Why reinvent
                  > something that already exists?
                  >[/color]

                  Printer friendly version of a document or a document selection might be
                  a reason to create a custom stylesheet for printing though.
                  [color=blue]
                  > And if the browser was such that printing was not possible even assuming
                  > a printer is attached, then surely javascript would also fail as a
                  > solution?
                  >
                  > I suppose the point is that you want to be able to print this window
                  > while still having the usual window interface hidden. This is one of the
                  > big reasons popup windows are hated - the interface is often hidden. But
                  > there is still control-P, or the best solution - no popups, or, if you
                  > must have popups, don't hide the interface.
                  >
                  >[/color]

                  Printing a selection of a document can be difficult or not working
                  (e.g.: Opera 7.x). Highlighting abs. positioned elements in MSIE 6 for
                  windows is difficult, e.g. a column in a 3 column webpage document.

                  I agree overall with what you say. I just see a few precise, specific
                  instances where printing from a requested popup might be needed or might
                  be a responsible webdesign decision.

                  DU

                  Comment

                  • Lasse Reichstein Nielsen

                    #10
                    Re: Problem printing popup pages.

                    DU <drunclear@hotW IPETHISmail.com > writes:
                    [color=blue]
                    > Michael Winter wrote:[/color]
                    ....[color=blue][color=green]
                    >> If a user wants to print a page, they can use their browser's
                    >> 'Print' command.[/color][/color]
                    ....[color=blue]
                    > I agree with the above. Nevertheless, there could be several reasons
                    > to create a custom stylesheet for printing.[/color]

                    Sure, but that doesn't require a new print button. Just add the
                    stylesheet with media="print", and it is only used for printing.

                    /L
                    --
                    Lasse Reichstein Nielsen - lrn@hotpop.com
                    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                    'Faith without judgement merely degrades the spirit divine.'

                    Comment

                    • Fabian

                      #11
                      Re: Problem printing popup pages.

                      DU hu kiteb:

                      [color=blue]
                      > I agree with the above. Nevertheless, there could be several reasons
                      > to create a custom stylesheet for printing.
                      >
                      > 1- remove webpage background color[/color]

                      I think all the major web browsers, those that are able to display
                      backgrounds anyway, include a built in option to strip background
                      colours when printing.
                      [color=blue]
                      > 2- display url values (hypertext links) and not text of links in the
                      > printed form[/color]

                      I wasn't aware stylesheets alone could do this.
                      [color=blue]
                      > 3- control page break
                      > 4- control font size[/color]

                      Since you have no way of knowing what paper size they are using, or how
                      good the guy's eyesight is, forcing page breaks or font size is a VERY
                      bad idea.

                      --
                      --
                      Fabian
                      Visit my website often and for long periods!


                      Comment

                      • Dr John Stockton

                        #12
                        Re: Problem printing popup pages.

                        JRS: In article <IBRvb.2332$B03 .1352304@newsfe p2-win.server.ntli .net>,
                        seen in news:comp.lang. javascript, Lee Mundie
                        <lee.j.mundie@n tlworld.com> posted at Sat, 22 Nov 2003 22:40:38 :-

                        If you read the newsgroup FAQ, you can find out how responses should be
                        formatted; if you heed this, people will not feel the need to write
                        "Please don't top-post", "Please don't over-quote", etc.; and will be
                        more likely to answer what you want.
                        [color=blue]
                        >Hmmm, didn't think that was fair... 3 x three worded reasons:
                        >
                        >User enhanced experience
                        >Useability and accessibility
                        >Human Centered Interfaces...
                        >
                        >Should always assume that a person has peripherals attached and design to
                        >cover... a printer being the most basic and common.[/color]

                        If you are dealing with a Company Intranet, you may be entitled to
                        assume that the material *must* be printed, and that a printer *will* be
                        connected. Even then, will it necessarily have the right sort of paper?

                        I have a printer connected, but not turned on; and I would not want you
                        to be able to choose to waste my ink and paper.

                        Printing without explicit user assent from a Web page should be
                        impossible.

                        --
                        © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                        <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                        <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
                        <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

                        Comment

                        • DU

                          #13
                          Re: Problem printing popup pages.

                          Fabian wrote:[color=blue]
                          > DU hu kiteb:
                          >
                          >
                          >[color=green]
                          >>I agree with the above. Nevertheless, there could be several reasons
                          >>to create a custom stylesheet for printing.
                          >>
                          >>1- remove webpage background color[/color]
                          >
                          >
                          > I think all the major web browsers, those that are able to display
                          > backgrounds anyway, include a built in option to strip background
                          > colours when printing.
                          >[/color]

                          Correct.
                          [color=blue]
                          >[color=green]
                          >>2- display url values (hypertext links) and not text of links in the
                          >>printed form[/color]
                          >
                          >
                          > I wasn't aware stylesheets alone could do this.
                          >[/color]

                          a:link:after { content: " (" attr(href) ") "; }
                          [color=blue]
                          >[color=green]
                          >>3- control page break
                          >>4- control font size[/color]
                          >
                          >
                          > Since you have no way of knowing what paper size they are using, or how
                          > good the guy's eyesight is, forcing page breaks or font size is a VERY
                          > bad idea.
                          >[/color]

                          For font size, you may be right. The user can still override the
                          author's suggested font-size value with the browsers' page setup (Print
                          preview in MSIE 6) printing options. I checked NS 7.1, Mozilla 1.5, MSIE
                          6 for windows and Opera 7.23 and they all allow users to scale the font
                          size in %percentage of the author's font-size. I did not test this though.

                          Regarding page break, I was thinking about all the page media style
                          properties. These are quite useful. Let's say you have a big table (or a
                          big element like an image) and you do not want it to be broken on 2
                          pages: then page-break-before is useful. Currently, Opera 7.x, NS 7.x
                          and Mozilla 1.3+ support page-break-before.



                          Such style sheet is still an author stylesheet. Users can still control
                          a few properties via page setup or print preview dialog boxes. I must
                          say I need to test all this.

                          I think everyone who replied that there was no need for javascript to
                          print a page was correct. I just think it was more according to the
                          spirit of usability to suggest to the original poster to work on
                          creating a custom stylesheet for printing.

                          DU

                          Comment

                          • Fabian

                            #14
                            Re: Problem printing popup pages.

                            DU hu kiteb:
                            [color=blue]
                            > Fabian wrote:[color=green]
                            >> DU hu kiteb:[/color][/color]
                            [color=blue][color=green][color=darkred]
                            >>> 2- display url values (hypertext links) and not text of links in the
                            >>> printed form[/color]
                            >>
                            >>
                            >> I wasn't aware stylesheets alone could do this.
                            >>[/color]
                            >
                            > a:link:after { content: " (" attr(href) ") "; }[/color]

                            I just tested this; it doesn't appear to work, or does it only have the
                            expected effect when printing to a printer, and not to a screen? Where
                            is the reference for this? I agree this would be VERY useful if it
                            consistently worked across environments.


                            --
                            --
                            Fabian
                            Visit my website often and for long periods!


                            Comment

                            • DU

                              #15
                              Re: Problem printing popup pages.

                              Fabian wrote:[color=blue]
                              > DU hu kiteb:
                              >
                              >[color=green]
                              >>Fabian wrote:
                              >>[color=darkred]
                              >>>DU hu kiteb:[/color][/color]
                              >
                              >[color=green][color=darkred]
                              >>>>2- display url values (hypertext links) and not text of links in the
                              >>>>printed form
                              >>>
                              >>>
                              >>>I wasn't aware stylesheets alone could do this.
                              >>>[/color]
                              >>
                              >>a:link:afte r { content: " (" attr(href) ") "; }[/color]
                              >
                              >
                              > I just tested this; it doesn't appear to work, or does it only have the
                              > expected effect when printing to a printer, and not to a screen?[/color]

                              You should see the link values in the print preview window.

                              Where[color=blue]
                              > is the reference for this?[/color]

                              See
                              Say no to “printer-friendly” versions and yes to printer-specific style sheets. CSS expert Eric Meyer shows how to conceive and design print style sheets that automatically format web c…


                              I agree this would be VERY useful if it[color=blue]
                              > consistently worked across environments.
                              >
                              >[/color]


                              The following documents are valid, validated, tested (printed) and
                              working for Mozilla 1.5, K-meleon 0.8 (build 844), NS 7.1, Opera 7.23.
                              Opera 7.23 had the best printed rendering (no extra blank spaces like
                              Mozilla does). MSIE 6 for windows did not render the link values at all.

                              DU

                              ----------------------

                              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                              "http://www.w3.org/TR/html4/strict.dtd">

                              <html lang="en-us">

                              <head>

                              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                              <meta http-equiv="Content-Language" content="en-us">
                              <meta http-equiv="Content-Style-Type" content="text/css">
                              <meta http-equiv="Content-Script-Type" content="text/javascript">

                              <title>Testin g custom print stylesheet</title>

                              <link rel="stylesheet " type="text/css" href="print.css " media="print">

                              </head>

                              <body>

                              <p>A few sites to visit:</p>

                              <ul>
                              <li><a href="http://www.lajzar.co.u k">Fabian's site</a></li>
                              <li><a
                              href="http://www.westciv.com/style_master/academy/browser_support/printing.html"> Browser
                              support for CSS2 properties in media print</a></li>
                              <li><a href="http://www.alistapart. com/articles/goingtoprint/">CSS
                              Design: Going to Print</a></li>
                              <li><a href="http://validator.w3.or g/">W3C HTML validation</a></li>
                              <li><a href="http://checkie.orange-soft.com/index.htm">Mult i-validator
                              plug-in for MSIE (Spanish)</a></li>
                              </ul>

                              </body></html>



                              print.css
                              ---------

                              a:link:after, a:visited:after {content: " ( " attr(href) " )";}


                              Comment

                              Working...