473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

catch print event with client-side javascript?

mp
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

Jul 23 '05 #1
17 12321
VK
did you look at onBeforePrint event? i'm not sure if it isn't IE specific
though.
Jul 23 '05 #2
VK wrote:
did you look at onBeforePrint event? i'm not sure if it isn't IE specific
though.


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]
Jul 23 '05 #3
VK
> > did you look at onBeforePrint event? i'm not sure if it isn't IE
specific
though.


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


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?
Jul 23 '05 #4
VK wrote:
> did you look at onBeforePrint event? i'm not sure if it isn't IE specific ^^
Please read <http://insideoe.tomsterdam.com/> to get informed about the bugs
in the software you are using and how to work around them. Broken quoting
is inappropriate.
> though.


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


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.
Sometimes you just cannot reach the same result in the same way on
different browsers. Then you have to "clue" together several solutions.
You are missing the point.
In this case: is there any specific workaround for Mozilla-based browsers?


I don't know of any, and in fact I fail to see why such thing would be
necessary.
PointedEars
Jul 23 '05 #5
VK wrote:
> did you look at onBeforePrint event? i'm not sure if it isn't IE specific ^^
Please read <http://insideoe.tomsterdam.com/> to get informed about the bugs
in the software you are using and how to work around them. Broken quoting
is inappropriate.
> though.


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


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*.
Sometimes you just cannot reach the same result in the same way on
different browsers. Then you have to "clue" together several solutions.
You are missing the point.
In this case: is there any specific workaround for Mozilla-based browsers?


I don't know of any, and in fact I fail to see why such thing would be
necessary.
PointedEars
Jul 23 '05 #6
Thomas 'PointedEars' Lahn wrote:
VK wrote:

<snip>
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*.

<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.
Jul 23 '05 #7
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
VK wrote: <snip>
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*.

<snip>

Bullshit!


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


There is no standards compliant or even officially recommended
"onbeforeprint" 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.
Jul 23 '05 #8
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
VK wrote:

<snip>
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*.

<snip>
Bullshit!

You may call it like you want, it is nevertheless true.


No it's not.
It is completely appropriate to use any feature implemented by
any browser (or number of browsers) regardless of how common its
implementation is. [...]

There is no standards compliant or even officially recommended
"onbeforeprint" 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".


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

window.onbeforeprint = 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.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #9
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
VK wrote:

<snip>
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*.

<snip>

Bullshit!


You may call it like you want, it is nevertheless true.


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.
It is completely appropriate to use any feature implemented by
any browser (or number of browsers) regardless of how common its
implementation is. [...]


There is no standards compliant or even officially recommended
"onbeforeprint" 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".


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

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


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.)
making the document dependent on a certain UA and vendor and
less future-proof.


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.
Jul 23 '05 #11
On Sun, 10 Oct 2004 20:53:46 +0200, Thomas 'PointedEars' Lahn
<Po*********@web.de> wrote:

[snip]
There is no standards compliant or even officially recommended
"onbeforeprint" event handler attribute, using it creates invalid HTML,
making the document dependent on a certain UA and vendor and less
future-proof.
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].
So far for your "assessment".


"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.
Jul 23 '05 #12
Jim Ley wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
Richard Cornford wrote:
It is completely appropriate to use any feature implemented by
any browser (or number of browsers) regardless of how common its
implementation is. [...]
There is no standards compliant or even officially recommended
"onbeforeprint" event handler attribute, using it creates invalid
HTML,


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.)


Example?
making the document dependent on a certain UA and vendor and
less future-proof.


[...]
Equally, the W3C have stated that HTML 4.01 is the last HTML, and
XHTML 1.0 the last thing servable as text/html


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.
- so future proof is meaningless in text/html document content terms.


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.infosystems.www.authoring.html

PointedEars
--
And on the 8th day He said, OK Murphy, you take over.
Jul 23 '05 #13
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
It is completely appropriate to use any feature implemented by
any browser (or number of browsers) regardless of how common its
implementation is. [...]


There is no standards compliant or even officially recommended
"onbeforeprint" 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".


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


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.
Jul 23 '05 #14
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:

Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:

It is completely appropriate to use any feature implemented by
any browser (or number of browsers) regardless of how common its
implementation is. [...]

There is no standards compliant or even officially recommended
"onbeforeprint" 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".


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

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.


No, using window.onbeforeprint 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.javascript 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?
Jul 23 '05 #15
The event "onbeforeprint" has been defined by the W3C for HTML 4.x and
should trigger as expected on all browser platforms which support HTML
4.x.

Therefore, if i have one thing to say to MS:
Why "if(self.print)" is working well and "if(self.onbeforeprint)" isn't
supported ?

Martin.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #16
On 21 Oct 2004 00:18:20 GMT, martin froment <fr*****@hotmail.com>
wrote:
The event "onbeforeprint" has been defined by the W3C for HTML 4.x and
should trigger as expected on all browser platforms which support HTML
4.x.
Could you point me to the relevant part of the W3C specification?

as
http://www.google.com/search?&q=onbe...+site%3Aw3.org

returns no documents, suggesting as I thought onbeforeprint is an IE
extension, as MS themselves think it is:

| Standards Information
|
| There is no public standard that applies to this event.

Now I know the HTML WG can go a little crazy sometimes, they're nice
people, but I think they would've documented it and not just told you.
Therefore, if i have one thing to say to MS:
Why "if(self.print)" is working well and "if(self.onbeforeprint)" isn't
supported ?


onbeforeprint works fine in IE.

Jim.
Jul 23 '05 #17
My error... I will search further next time before posting. My sources
was invalid...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sveta | last post by:
Hi, all! I am new with J2ME. I have application that has form with 2 commands (exit and select). All UI uses are high level API, and it is very important to leave it high-level. This...
1
by: Supa Hoopsa | last post by:
I have a standard combo box in a datagrid (DataGridEnableComboBoxColumn) and I want to catch the SelectionChangeCommitted event. Does anyone know how to do this?
0
by: Phuff | last post by:
I need to be able to capture events thrown by the Amyuni print driver( a 3rd parter pdf conversion product), and it has specified numbers which I believe I understand to be thw wParam of the print...
2
by: Roger | last post by:
I've got a table with one field (id) and one row (id = 1) I've got a query based on the table that calls a function select func(id) as idText from table The function 'func' is public...
5
by: Tom Louchbaum | last post by:
When I preview my Access 2000 Report it looks fine. When I Email the report using DoCmd.SendObject acSendReport, "Report", acFormatRTF, "To Address", , , "Subject", , False the resulting...
2
by: D. Alvarado | last post by:
Hi, Basically, I want to run an action every time I detect a new file appears in a particular directory. I realize I could poll the directory every 5-10 seconds or so, but I was hoping there was...
1
by: Richard Hollenbeck | last post by:
I noticed I can't push a value into a text box by saying something like, "txtThisTextBox = intSomeVariable * 0.5" because I get an run-time error saying I can't assign a value to this object....
0
by: Benny Chow | last post by:
Hello All, Currently I am working on a web application using VS.NET (c#). I have created a Template Column with a checkbox in the ItemTemplate. I want to do some calculations when the user...
2
by: tony | last post by:
Hello! I have a mainManu where I can chose to display some window forms. When the mainMenu is minimized I need to minimize every window form that is started from the mainMenu. So I need to...
2
by: Rossouw | last post by:
Good day, I was wondering if there is a way to catch the print event of Microsoft Outlook, or some way to write macros to run an event before printing an email. The reason for this is, it seems...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.