Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > html javascript print command

Reply
Thread Tools

html javascript print command

 
 
tigeressal
Guest
Posts: n/a
 
      04-12-2008
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
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      04-12-2008
tigeressal wrote:
> 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...


> 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
 
 
 
 
PW
Guest
Posts: n/a
 
      04-12-2008

"tigeressal" <> wrote in message
news:d55be8e6-f177-4337-b2d2-...
> 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
 
PW
Guest
Posts: n/a
 
      04-12-2008
>
> 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
 
Jonathan N. Little
Guest
Posts: n/a
 
      04-12-2008
PW wrote:
> "tigeressal" <> wrote in message
> news:d55be8e6-f177-4337-b2d2-...
>> 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
 
tigeressal
Guest
Posts: n/a
 
      04-12-2008
On Apr 12, 3:35*am, "Jonathan N. Little" <lws4...@central.net> wrote:
> PW wrote:
> > "tigeressal" <> wrote in message
> >news:d55be8e6-f177-4337-b2d2-...


snipped

> >> rak

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


snipped

> > 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
 
Andy Dingley
Guest
Posts: n/a
 
      04-12-2008
On 12 Apr, 22:12, Ed Jay <ed...@aes-intl.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.
 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      04-12-2008
Andy Dingley wrote:
> On 12 Apr, 22:12, Ed Jay <ed...@aes-intl.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
 
Andy Dingley
Guest
Posts: n/a
 
      04-13-2008
On 12 Apr, 23:59, "Jonathan N. Little" <lws4...@central.net> wrote:

> 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
 
Travis Newbury
Guest
Posts: n/a
 
      04-13-2008
On Apr 12, 5:12 pm, Ed Jay <ed...@aes-intl.com> wrote:
> It is impossible to do via code...


Ed, are your comment so unimportant that you don't think anyone will
want to read them after a week, or are you just selfish?
 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
print a vs print '%s' % a vs print '%f' a David Cournapeau Python 0 12-30-2008 03:19 AM
html javascript print command cdrakz Computer Support 1 04-13-2008 01:23 PM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
Print HTML Report Page or Print multiple application pages Sam ASP .Net 1 11-10-2006 10:05 PM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57