Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Print web page ?

Reply
Thread Tools

Print web page ?

 
 
RAYMOND PISTEY
Guest
Posts: n/a
 
      05-03-2010
Hello on my site this is what is happenning

Part 1 - This is what works and prints me output I like from <print> link in
body section

<head>
<script type="text/javascript">
function ClickHereToPrint(){
try{
var oIframe = document.getElementById('ifrmPrint');
var oContent = document.getElementById('divToPrint').innerHTML;
var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
if (oDoc.document) oDoc = oDoc.document;
oDoc.write("<html><head><title>title</title>");
oDoc.write("</head><body onload='this.focus(); this.print();'>");
oDoc.write(oContent + "</body></html>");
oDoc.close();
}
catch(e){
self.print();
}
}
</script>
</head>


<body>

<a onclick="ClickHereToPrint();">Print</a>

<iframe id='ifrmPrint' src='#' style="width:0px; height:0px;"></iframe>


<div id="divToPrint">
content
</div>
</body>

PART 2 - How do I change the file, print menu item to use my part 1 code

window.print?

Thanks

Ray

 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      05-03-2010
RAYMOND PISTEY wrote:

> Hello on my site this is what is happenning


This seems to relate to your previous message "button from this code", with
no reference to it.

> Part 1 - This is what works and prints me output I like from <print>
> link in body section


You still don't specify a URL or tell what you are actually trying to
accomplish.

> <iframe id='ifrmPrint' src='#' style="width:0px;
> height:0px;"></iframe>


It looks like you are trying to create problems, instead of solving any. You
can disprove this impression by providing a URL and an understandable
explanation of what you are trying to do (instead of fragments of code
supposed to solve an unspecified problem).

--
Yucca, http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
 
 
 
cwdjrxyz
Guest
Posts: n/a
 
      05-03-2010
On May 2, 7:05*pm, "RAYMOND PISTEY" <(E-Mail Removed)> wrote:
> Hello on my site this is what is happenning
>
> Part 1 - This is what works and prints me output I like from <print> link in
> body section
>
> <head>
> <script type="text/javascript">
> function ClickHereToPrint(){
> * * try{
> * * * * var oIframe = document.getElementById('ifrmPrint');
> * * * * var oContent = document.getElementById('divToPrint').innerHTML;
> * * * * var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
> * * * * if (oDoc.document) oDoc = oDoc.document;
> * oDoc.write("<html><head><title>title</title>");
> * oDoc.write("</head><body onload='this.focus(); this.print();'>");
> * oDoc.write(oContent + "</body></html>");
> * oDoc.close();
> * * }
> * * catch(e){
> * * *self.print();
> * * }}
>
> </script>
> </head>
>
> <body>
>
> <a onclick="ClickHereToPrint();">Print</a>
>
> *<iframe id='ifrmPrint' src='#' style="width:0px; height:0px;"></iframe>
>
> <div id="divToPrint">
> * content
> *</div>
> </body>
>
> PART 2 - *How do I change the file, print menu item to use my part 1 code
>
> window.print?


Someone will be better able to help if you give the url for a complete
working example without the button. However I will point out that you
are using javascript, and thus your print link will not work for
browsers that have script turned off. See http://www.w3schools.com/browsers/browsers_stats.asp
near the bottom of the page. At one time many turned their script off,
but perhaps only about 5% of visitors to the w3schools site now do.
This may or may not be typical of other sites. In some cases one can
use server side scripting, such as php, to avoid this problem. Also
you might use a no script path that gives text instructions for
printing if there is not script support.

 
Reply With Quote
 
RAYMOND PISTEY
Guest
Posts: n/a
 
      05-04-2010
Fixed it using the browser print, by placing div where i wanted, sorry
newbie here

"cwdjrxyz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On May 2, 7:05 pm, "RAYMOND PISTEY" <(E-Mail Removed)> wrote:
> Hello on my site this is what is happenning
>
> Part 1 - This is what works and prints me output I like from <print> link
> in
> body section
>
> <head>
> <script type="text/javascript">
> function ClickHereToPrint(){
> try{
> var oIframe = document.getElementById('ifrmPrint');
> var oContent = document.getElementById('divToPrint').innerHTML;
> var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
> if (oDoc.document) oDoc = oDoc.document;
> oDoc.write("<html><head><title>title</title>");
> oDoc.write("</head><body onload='this.focus(); this.print();'>");
> oDoc.write(oContent + "</body></html>");
> oDoc.close();
> }
> catch(e){
> self.print();
> }}
>
> </script>
> </head>
>
> <body>
>
> <a onclick="ClickHereToPrint();">Print</a>
>
> <iframe id='ifrmPrint' src='#' style="width:0px; height:0px;"></iframe>
>
> <div id="divToPrint">
> content
> </div>
> </body>
>
> PART 2 - How do I change the file, print menu item to use my part 1 code
>
> window.print?


Someone will be better able to help if you give the url for a complete
working example without the button. However I will point out that you
are using javascript, and thus your print link will not work for
browsers that have script turned off. See
http://www.w3schools.com/browsers/browsers_stats.asp
near the bottom of the page. At one time many turned their script off,
but perhaps only about 5% of visitors to the w3schools site now do.
This may or may not be typical of other sites. In some cases one can
use server side scripting, such as php, to avoid this problem. Also
you might use a no script path that gives text instructions for
printing if there is not script support.

 
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
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
Firefox 2 print and print preview only shows first page R.Ig Firefox 3 02-14-2007 01:10 AM
Print and print overview and current page Bernard Segonnes Java 0 11-04-2004 02:48 PM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments