catch print event with client-side javascript?

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

    #1

    catch print event with client-side javascript?

    Hi.

    I know I can use "window.print() " to print a page, but is there a way to
    catch a print event when someone prints a document from the browser?

    Thanks.

    mp

  • VK

    #2
    Re: catch print event with client-side javascript?

    did you look at onBeforePrint event? i'm not sure if it isn't IE specific
    though.


    Comment

    • Thomas 'PointedEars' Lahn

      #3
      Re: catch print event with client-side javascript?

      VK wrote:
      [color=blue]
      > did you look at onBeforePrint event? i'm not sure if it isn't IE specific
      > though.[/color]

      It *is* IE specific and therefore not to be recommended on the global Web.


      PointedEars
      --
      For some reason, reading right through the entire quip list seemed a helluva
      lot more attractive than doing some FoxPro development... Can't imagine
      why! [www.rubberturnip.org.uk]

      Comment

      • VK

        #4
        Re: catch print event with client-side javascript?

        > > did you look at onBeforePrint event? i'm not sure if it isn't IE
        specific[color=blue][color=green]
        > > though.[/color]
        >
        > It *is* IE specific and therefore not to be recommended on the global Web.[/color]

        IMHO it's totally OK to mention browser-specific methods and property, as
        long as you mark it in your posting (IE only, may not work in X, etc)

        Sometimes you just cannot reach the same result in the same way on different
        browsers. Then you have to "clue" together several solutions.

        In this case: is there any specific workaround for Mozilla-based browsers?


        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: catch print event with client-side javascript?

          VK wrote:
          [color=blue][color=green][color=darkred]
          >> > did you look at onBeforePrint event? i'm not sure if it isn't IE[/color][/color]
          > specific[/color]
          ^^
          Please read <http://insideoe.tomste rdam.com/> to get informed about the bugs
          in the software you are using and how to work around them. Broken quoting
          is inappropriate.
          [color=blue][color=green][color=darkred]
          >> > though.[/color]
          >>
          >> It *is* IE specific and therefore not to be recommended on the global
          >> Web.[/color]
          >
          > IMHO it's totally OK to mention browser-specific methods and property, as
          > long as you mark it in your posting (IE only, may not work in X, etc)[/color]

          I have not stated the opposite. Of course it is OK to mention it (and
          yes, it is then required to mark it as proprietary), however it is not
          recommended to *use* it.
          [color=blue]
          > Sometimes you just cannot reach the same result in the same way on
          > different browsers. Then you have to "clue" together several solutions.[/color]

          You are missing the point.
          [color=blue]
          > In this case: is there any specific workaround for Mozilla-based browsers?[/color]

          I don't know of any, and in fact I fail to see why such thing would be
          necessary.


          PointedEars

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: catch print event with client-side javascript?

            VK wrote:
            [color=blue][color=green][color=darkred]
            >> > did you look at onBeforePrint event? i'm not sure if it isn't IE[/color][/color]
            > specific[/color]
            ^^
            Please read <http://insideoe.tomste rdam.com/> to get informed about the bugs
            in the software you are using and how to work around them. Broken quoting
            is inappropriate.
            [color=blue][color=green][color=darkred]
            >> > though.[/color]
            >>
            >> It *is* IE specific and therefore not to be recommended on the global
            >> Web.[/color]
            >
            > IMHO it's totally OK to mention browser-specific methods and property, as
            > long as you mark it in your posting (IE only, may not work in X, etc)[/color]

            I have not stated the opposite. Of course it is OK to mention it (and
            yes, it is then required to mark it as proprietary), however it is not
            recommended to *use it on the global Web*.
            [color=blue]
            > Sometimes you just cannot reach the same result in the same way on
            > different browsers. Then you have to "clue" together several solutions.[/color]

            You are missing the point.
            [color=blue]
            > In this case: is there any specific workaround for Mozilla-based browsers?[/color]

            I don't know of any, and in fact I fail to see why such thing would be
            necessary.


            PointedEars

            Comment

            • Richard Cornford

              #7
              Re: catch print event with client-side javascript?

              Thomas 'PointedEars' Lahn wrote:[color=blue]
              > VK wrote:[/color]
              <snip>[color=blue][color=green]
              >> IMHO it's totally OK to mention browser-specific methods and
              >> property, as long as you mark it in your posting (IE only,
              >> may not work in X, etc)[/color]
              >
              > I have not stated the opposite. Of course it is OK to mention
              > it (and yes, it is then required to mark it as proprietary),
              > however it is not recommended to *use it on the global Web*.[/color]
              <snip>

              Bullshit! It is completely appropriate to use any feature implemented by
              any browser (or number of browsers) regardless of how common its
              implementation is. If the implementation is designed as an enhancement,
              and clean degradation is facilitated in the design, then users of
              browsers that do not support any given feature are no worse off than the
              users of browsers that do not support scripting at all.

              Richard.


              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: catch print event with client-side javascript?

                Richard Cornford wrote:
                [color=blue]
                > Thomas 'PointedEars' Lahn wrote:[color=green]
                >> VK wrote:[/color]
                > <snip>[color=green][color=darkred]
                >>> IMHO it's totally OK to mention browser-specific methods and
                >>> property, as long as you mark it in your posting (IE only,
                >>> may not work in X, etc)[/color]
                >>
                >> I have not stated the opposite. Of course it is OK to mention
                >> it (and yes, it is then required to mark it as proprietary),
                >> however it is not recommended to *use it on the global Web*.[/color]
                > <snip>
                >
                > Bullshit![/color]

                You may call it like you want, it is nevertheless true.
                [color=blue]
                > It is completely appropriate to use any feature implemented by
                > any browser (or number of browsers) regardless of how common its
                > implementation is. [...][/color]

                There is no standards compliant or even officially recommended
                "onbeforepr int" event handler attribute, using it creates invalid
                HTML, making the document dependent on a certain UA and vendor and
                less future-proof. So far for your "assessment ".


                PointedEars
                --
                If the wind changes it will freeze like that.

                Comment

                • Randy Webb

                  #9
                  Re: catch print event with client-side javascript?

                  Thomas 'PointedEars' Lahn wrote:
                  [color=blue]
                  > Richard Cornford wrote:[color=green]
                  >>Thomas 'PointedEars' Lahn wrote:[color=darkred]
                  >>>VK wrote:[/color]
                  >><snip>[color=darkred]
                  >>>>IMHO it's totally OK to mention browser-specific methods and
                  >>>>property, as long as you mark it in your posting (IE only,
                  >>>>may not work in X, etc)
                  >>>
                  >>>I have not stated the opposite. Of course it is OK to mention
                  >>>it (and yes, it is then required to mark it as proprietary),
                  >>>however it is not recommended to *use it on the global Web*.[/color]
                  >><snip>
                  >>Bullshit![/color]
                  > You may call it like you want, it is nevertheless true.[/color]

                  No it's not.
                  [color=blue][color=green]
                  >>It is completely appropriate to use any feature implemented by
                  >>any browser (or number of browsers) regardless of how common its
                  >>implementatio n is. [...][/color]
                  > There is no standards compliant or even officially recommended
                  > "onbeforepr int" event handler attribute, using it creates invalid
                  > HTML, making the document dependent on a certain UA and vendor and
                  > less future-proof. So far for your "assessment ".[/color]

                  It doesn't "create invalid HTML" if done properly.

                  window.onbefore print = myFunction;
                  function myFunction(){}

                  Before you babble incoherently about what "creates invalid HTML" and
                  what doesn't, perhaps you should learn a little more about scripting.

                  --
                  Randy
                  comp.lang.javas cript FAQ - http://jibbering.com/faq

                  Comment

                  • Richard Cornford

                    #10
                    Re: catch print event with client-side javascript?

                    Thomas 'PointedEars' Lahn wrote:[color=blue]
                    > Richard Cornford wrote:[color=green]
                    >> Thomas 'PointedEars' Lahn wrote:[color=darkred]
                    >>> VK wrote:[/color]
                    >> <snip>[color=darkred]
                    >>>> IMHO it's totally OK to mention browser-specific methods and
                    >>>> property, as long as you mark it in your posting (IE only,
                    >>>> may not work in X, etc)
                    >>>
                    >>> I have not stated the opposite. Of course it is OK to mention
                    >>> it (and yes, it is then required to mark it as proprietary),
                    >>> however it is not recommended to *use it on the global Web*.[/color]
                    >> <snip>
                    >>
                    >> Bullshit![/color]
                    >
                    > You may call it like you want, it is nevertheless true.[/color]

                    If there are people recommending never using proprietary features of web
                    browsers on the Internet then they are clueless half-wits, and what they
                    are proposing is bullshit.

                    The capabilities of any browser can be exploited to its fullest
                    regardless of what those capabilities are, and so long the action of the
                    script is an optional enhancement and clean degradation is facilitated
                    in the script design it doesn't matter one jot if only the users of one
                    version of one particular browsers get to experience the benefits.
                    [color=blue][color=green]
                    >> It is completely appropriate to use any feature implemented by
                    >> any browser (or number of browsers) regardless of how common its
                    >> implementation is. [...][/color]
                    >
                    > There is no standards compliant or even officially recommended
                    > "onbeforepr int" event handler attribute, using it creates invalid
                    > HTML, making the document dependent on a certain UA and vendor and
                    > less future-proof. So far for your "assessment ".[/color]

                    Not putting an invalid attribute in the HTML is no barrier to employing
                    the feature through scripting.

                    Richard.


                    Comment

                    • Jim Ley

                      #11
                      Re: catch print event with client-side javascript?

                      On Sun, 10 Oct 2004 20:53:46 +0200, Thomas 'PointedEars' Lahn
                      <PointedEars@we b.de> wrote:
                      [color=blue]
                      >Richard Cornford wrote:[color=green]
                      >> It is completely appropriate to use any feature implemented by
                      >> any browser (or number of browsers) regardless of how common its
                      >> implementation is. [...][/color]
                      >
                      >There is no standards compliant or even officially recommended
                      >"onbeforeprint " event handler attribute, using it creates invalid
                      >HTML,[/color]

                      No, it doesn't, there's plenty of ways of making a valid version of
                      HTML containing that attribute, or you could do it in the internal
                      subset. It wouldn't be a W3C recommended HTML (but so what, there's
                      lots of good HTML's ISO etc.)
                      [color=blue]
                      > making the document dependent on a certain UA and vendor and
                      >less future-proof.[/color]

                      Hmm, less future proof could be an argument - the existence of the
                      attribute in a UA does prevent other UA's implementing, or standards
                      orgs. from standardising it in a different way - but that's hardly a
                      danger in using it - creating it caused the problem.

                      Equally, the W3C have stated that HTML 4.01 is the last HTML, and
                      XHTML 1.0 the last thing servable as text/html - so future proof is
                      meaningless in text/html document content terms.

                      Jim.

                      Comment

                      • Michael Winter

                        #12
                        Re: catch print event with client-side javascript?

                        On Sun, 10 Oct 2004 20:53:46 +0200, Thomas 'PointedEars' Lahn
                        <PointedEars@we b.de> wrote:

                        [snip]
                        [color=blue]
                        > There is no standards compliant or even officially recommended
                        > "onbeforepr int" event handler attribute, using it creates invalid HTML,
                        > making the document dependent on a certain UA and vendor and less
                        > future-proof.[/color]

                        It only makes the document depend on IE if you let it. Read Richard's post
                        again (the part you removed). I believe he mentioned graceful
                        degradation[1].
                        [color=blue]
                        > So far for your "assessment ".[/color]

                        "So much for your assessment", was the phrase you were looking for.

                        Mike


                        [1] Or words to that effect. I'm deleting this thread, including this
                        recent set of posts. Richard's post is already irretrievable and Google
                        won't have the text for quite a while.

                        --
                        Michael Winter
                        Replace ".invalid" with ".uk" to reply by e-mail.

                        Comment

                        • Thomas 'PointedEars' Lahn

                          #13
                          Re: catch print event with client-side javascript?

                          Jim Ley wrote:
                          [color=blue]
                          > [...] Thomas 'PointedEars' Lahn [...] wrote:[color=green]
                          >> Richard Cornford wrote:[color=darkred]
                          >>> It is completely appropriate to use any feature implemented by
                          >>> any browser (or number of browsers) regardless of how common its
                          >>> implementation is. [...][/color]
                          >>
                          >> There is no standards compliant or even officially recommended
                          >> "onbeforepr int" event handler attribute, using it creates invalid
                          >> HTML,[/color]
                          >
                          > No, it doesn't, there's plenty of ways of making a valid version of
                          > HTML containing that attribute, or you could do it in the internal
                          > subset. It wouldn't be a W3C recommended HTML (but so what, there's
                          > lots of good HTML's ISO etc.)[/color]

                          Example?
                          [color=blue][color=green]
                          >> making the document dependent on a certain UA and vendor and
                          >>less future-proof.[/color]
                          >
                          > [...]
                          > Equally, the W3C have stated that HTML 4.01 is the last HTML, and
                          > XHTML 1.0 the last thing servable as text/html[/color]

                          Everything is servable as text/html, that does not mean it makes sense to do
                          so. Since XHTML SHORTTAG and HTML SHORTTAG differ and it is highly likely
                          that a tagsoup parser will be used to parse that XHTML as broken HTML, it
                          does not make sense to serve XHTML as text/html.
                          [color=blue]
                          > - so future proof is meaningless in text/html document content terms.[/color]

                          No, it is not. Because of the above, XHTML has failed to become a viable
                          alternative to HTML either, it can only serve as a supplement for compliant
                          UAs or on intranet sites with a defined UA environment.


                          X-Post & F'up2 comp.infosystem s.www.authoring.html

                          PointedEars
                          --
                          And on the 8th day He said, OK Murphy, you take over.

                          Comment

                          • Thomas 'PointedEars' Lahn

                            #14
                            Re: catch print event with client-side javascript?

                            Richard Cornford wrote:
                            [color=blue]
                            > Thomas 'PointedEars' Lahn wrote:[color=green]
                            >> Richard Cornford wrote:[color=darkred]
                            >>> It is completely appropriate to use any feature implemented by
                            >>> any browser (or number of browsers) regardless of how common its
                            >>> implementation is. [...][/color]
                            >>
                            >> There is no standards compliant or even officially recommended
                            >> "onbeforepr int" event handler attribute, using it creates invalid
                            >> HTML, making the document dependent on a certain UA and vendor and
                            >> less future-proof. So far for your "assessment ".[/color]
                            >
                            > Not putting an invalid attribute in the HTML is no barrier to employing
                            > the feature through scripting.[/color]

                            There is no barrier to that, true. I did not overlooked that alternative
                            as you might think, I just don't find that a viable solution as well, as
                            it requires one more feature test (and even this won't be enough to prevent
                            script errors) and I fail to see even the necessity of it.


                            PointedEars
                            --
                            The website you seek cannot be located, but countless more exist.

                            Comment

                            • Randy Webb

                              #15
                              Re: catch print event with client-side javascript?

                              Thomas 'PointedEars' Lahn wrote:
                              [color=blue]
                              > Richard Cornford wrote:
                              >
                              >[color=green]
                              >>Thomas 'PointedEars' Lahn wrote:
                              >>[color=darkred]
                              >>>Richard Cornford wrote:
                              >>>
                              >>>>It is completely appropriate to use any feature implemented by
                              >>>>any browser (or number of browsers) regardless of how common its
                              >>>>implementat ion is. [...]
                              >>>
                              >>>There is no standards compliant or even officially recommended
                              >>>"onbeforepri nt" event handler attribute, using it creates invalid
                              >>>HTML, making the document dependent on a certain UA and vendor and
                              >>>less future-proof. So far for your "assessment ".[/color]
                              >>
                              >>Not putting an invalid attribute in the HTML is no barrier to employing
                              >>the feature through scripting.[/color]
                              >
                              >
                              > There is no barrier to that, true. I did not overlooked that alternative
                              > as you might think, I just don't find that a viable solution as well, as
                              > it requires one more feature test (and even this won't be enough to prevent
                              > script errors) and I fail to see even the necessity of it.[/color]

                              No, using window.onbefore print does not require "one more feature test".
                              It simply sets a new attribute for the window object if the
                              onbeforeprint is not supported. I tested it (unlike you) before I ever
                              posted about it. It silently fails (read - no errors), in non-IE
                              browsers, as it should.

                              --
                              Randy
                              comp.lang.javas cript FAQ - http://jibbering.com/faq
                              Answer:It destroys the order of the conversation
                              Question: Why?
                              Answer: Top-Posting.
                              Question: Whats the most annoying thing on Usenet?

                              Comment

                              Working...