HighDots Forums  

html javascript print command

alt.html alt.html


Discuss html javascript print command in the alt.html forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
tigeressal
 
Posts: n/a

Default html javascript print command - 04-11-2008 , 08:21 PM






hi,
im new to this group but ill be direct to the point.

im tryin to create a simple webpage that will print the contents of
the webpage to a printer on a client side machine.

i know the command is ' window.print() ' and that i can have it in
the ' onload() ' statement so that the print dialouge appears prior to
printing.

here my question. how do i eliminate the Header and Footer information
that is automatically generated by the webpage?(i.e. the website name
at the top, and the location url at the bottom)

any help appreciated.

regards

rak

Reply With Quote
  #2  
Old   
Jonathan N. Little
 
Posts: n/a

Default Re: html javascript print command - 04-11-2008 , 09:06 PM






tigeressal wrote:
Quote:
hi,
im new to this group but ill be direct to the point.

im tryin to create a simple webpage that will print the contents of
the webpage to a printer on a client side machine.

i know the command is ' window.print() ' and that i can have it in
the ' onload() ' statement so that the print dialouge appears prior to
printing.
I wouldn't recommend it. Folks who browse the web expect to *see* a page
when it loads, if they want to print it they will click print from their
browser. Anyway what if they don't have a printer? Maybe they are view
the page from on of those iPhones...


Quote:
here my question. how do i eliminate the Header and Footer information
that is automatically generated by the webpage?(i.e. the website name
at the top, and the location url at the bottom)
You cannot, those are user settings on the browser. You cannot script them.


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com


Reply With Quote
  #3  
Old   
PW
 
Posts: n/a

Default Re: html javascript print command - 04-11-2008 , 09:18 PM




"tigeressal" <cdrakz2000 (AT) mynow (DOT) co.uk> wrote

Quote:
hi,
im new to this group but ill be direct to the point.

im tryin to create a simple webpage that will print the contents of
the webpage to a printer on a client side machine.

i know the command is ' window.print() ' and that i can have it in
the ' onload() ' statement so that the print dialouge appears prior to
printing.

here my question. how do i eliminate the Header and Footer information
that is automatically generated by the webpage?(i.e. the website name
at the top, and the location url at the bottom)

any help appreciated.

regards

rak



First, create a style like this ...
<style type="text/css">
<!--
@media print{.dontprintme{display:none;}}
-->
</style>



Next, whenever you are serving something that you don't want to be printed,
place it in a paragraph like this ...
(this is my print button by the way)
<p class="dontprintme">
<BUTTON TYPE=BUTTON onClick="window.print()"
style="width:250px;height:50px;">&nbsp&nbspPRINT&n bsp&nbsp</BUTTON>
<p>



Now, when you run the page, and you click the button, then everything thats
NOT within a 'dontprintme' paragraph will not be printed.

HTH,
PW







Reply With Quote
  #4  
Old   
PW
 
Posts: n/a

Default Re: html javascript print command - 04-11-2008 , 09:34 PM



Quote:
First, create a style like this ...
style type="text/css"
!--
@media print{.dontprintme{display:none;}}
--
/style



Next, whenever you are serving something that you don't want to be
printed, place it in a paragraph like this ...
(this is my print button by the way)
p class="dontprintme"
BUTTON TYPE=BUTTON onClick="window.print()"
style="width:250px;height:50px;">&nbsp&nbspPRINT&n bsp&nbsp</BUTTON
p



Now, when you run the page, and you click the button, then everything
thats NOT within a 'dontprintme' paragraph will not be printed.

HTH,
PW


OOPS, that should have said ...
Now, when you run the page, and you click the button, then everything thats
NOT within a 'dontprintme' paragraph WILL be printed.






Reply With Quote
  #5  
Old   
Jonathan N. Little
 
Posts: n/a

Default Re: html javascript print command - 04-11-2008 , 09:35 PM



PW wrote:
Quote:
"tigeressal" <cdrakz2000 (AT) mynow (DOT) co.uk> wrote in message
news:d55be8e6-f177-4337-b2d2-e5f0eede7ec4 (AT) b64g2000hsa (DOT) googlegroups.com...
hi,
im new to this group but ill be direct to the point.

im tryin to create a simple webpage that will print the contents of
the webpage to a printer on a client side machine.

i know the command is ' window.print() ' and that i can have it in
the ' onload() ' statement so that the print dialouge appears prior to
printing.

here my question. how do i eliminate the Header and Footer information
that is automatically generated by the webpage?(i.e. the website name
at the top, and the location url at the bottom)

any help appreciated.

regards

rak




First, create a style like this ...
style type="text/css"
!--
@media print{.dontprintme{display:none;}}
--
/style



Next, whenever you are serving something that you don't want to be printed,
place it in a paragraph like this ...
(this is my print button by the way)
p class="dontprintme"
BUTTON TYPE=BUTTON onClick="window.print()"
style="width:250px;height:50px;">&nbsp&nbspPRINT&n bsp&nbsp</BUTTON
p
Ah, but what OP want to excluded is not part of his web page that he
composed but the URL and date and page numbers that is added by the
browser by default. This is a user setting on the browser and is not
controllable by the web author...at least with HTML and CSS


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com


Reply With Quote
  #6  
Old   
Sid
 
Posts: n/a

Default Re: html javascript print command - 04-12-2008 , 11:55 AM



On Fri, 11 Apr 2008 22:35:05 -0400, "Jonathan N. Little"
<lws4art (AT) central (DOT) net> wrote:

: > <!--
: > @media print{.dontprintme{display:none;}}
: > -->
: > </style>
: >
: >
: >
: > Next, whenever you are serving something that you don't want to be printed,
: > place it in a paragraph like this ...
: > (this is my print button by the way)
: > <p class="dontprintme">
: > <BUTTON TYPE=BUTTON onClick="window.print()"
: > style="width:250px;height:50px;">&nbsp&nbspPRINT&n bsp&nbsp</BUTTON>
: > <p>
:
: Ah, but what OP want to excluded is not part of his web page that he
: composed but the URL and date and page numbers that is added by the
: browser by default. This is a user setting on the browser and is not
: controllable by the web author...at least with HTML and CSS


The easiest way for the OP to achieve this would be to PDF it.

Sid


Reply With Quote
  #7  
Old   
tigeressal
 
Posts: n/a

Default Re: html javascript print command - 04-12-2008 , 03:41 PM



On Apr 12, 3:35*am, "Jonathan N. Little" <lws4... (AT) central (DOT) net> wrote:
Quote:
PW wrote:
"tigeressal" <cdrakz (AT) nw (DOT) co.uk> wrote in message
news:d55be8e6-f177-4337-b2d2-e5f0eede7ec4 (AT) b64g2000hsa (DOT) googlegroups.com...
snipped

Quote:
rak

First, create a style like this ...
style type="text/css"
snipped

Quote:
style="width:250px;height:50px;">&nbsp&nbspPRINT&n bsp&nbsp</BUTTON
p

Ah, but what OP want to excluded is not part of his web page that he
composed but the URL and date and page numbers that is added by the
browser by default. This is a user setting on the browser and is not
controllable by the web author...at least with HTML and CSS

--
Take care,

Jonathan
-------------------
Hi thanks for the reply, You said its not possible with HTML or CSS.
Is there a way to do it by other langauges (i.e. specifically PHP)

Just to let people know, the webpage in question will NOT be on the
internet but instead on a local nework.
The printer in question is connected to a client side computer by
usb.
AND the end user WILL want to print the page as it will be part of a
particular process.

thanks

rak



Reply With Quote
  #8  
Old   
Andy Dingley
 
Posts: n/a

Default Re: html javascript print command - 04-12-2008 , 04:33 PM



On 12 Apr, 22:12, Ed Jay <ed... (AT) aes-intl (DOT) com> wrote:

Quote:
It is impossible to do via code. It's hard coded into the browser.
It's not hard-coded into the browser, it's configurable. Some browsers
may have a programming interface that exposes this, and lets you
control it. This is likely to be very browser-specific. IE certainly
does have this, although it requires COM (ad thus ActiveX). If you use
MeadCo's ScriptX control on your page, it's pretty easy.


Reply With Quote
  #9  
Old   
Jonathan N. Little
 
Posts: n/a

Default Re: html javascript print command - 04-12-2008 , 05:59 PM



Andy Dingley wrote:
Quote:
On 12 Apr, 22:12, Ed Jay <ed... (AT) aes-intl (DOT) com> wrote:

It is impossible to do via code. It's hard coded into the browser.

It's not hard-coded into the browser, it's configurable. Some browsers
may have a programming interface that exposes this, and lets you
control it. This is likely to be very browser-specific. IE certainly
does have this, although it requires COM (ad thus ActiveX). If you use
MeadCo's ScriptX control on your page, it's pretty easy.
Ol' wild and woolly IE! Same business lets to do all kinds of damage.
But now with MS's attempt at securing IE won't you get a zillion warning
dialogs when you invoke such ActiveX? It would hardly be a feasible
solution. Generate PDF would be the way...some freebee PHP packages out
there, fpdf comes to mind.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com


Reply With Quote
  #10  
Old   
Andy Dingley
 
Posts: n/a

Default Re: html javascript print command - 04-13-2008 , 05:17 AM



On 12 Apr, 23:59, "Jonathan N. Little" <lws4... (AT) central (DOT) net> wrote:

Quote:
But now with MS's attempt at securing IE won't you get a zillion warning
dialogs when you invoke such ActiveX? It would hardly be a feasible
solution.
No, you can get away with just setting trust up once. As an app that
_needs_ to control print sizes is probably something that the user has
a non-trivial relationship with, this might be enough.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.