Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Button To Print Current Web Page


22 replies to this topic

#21 Guest_Swapnochari_*

  • Guests

Posted 19 May 2011 - 07:03 AM

View PostiGuest, on 20 February 2010 - 08:37 AM, said:

How to print directlyButton To Print Current Web PageHOW TO PRINT DIRECTLYButton To Print Current Web PageI need to print the ticket of size 3" x 8". By simply pressing the button Print. Without even displaying any dialog box. If someone can help that's going to help me. Thanks in adv -question by CALKA-question by CaLkA


I want to print an specific cell of a table in a html page, you all r yalking abt printing the whole page. nac anybody suggest how to print specific area/cell of a table ??
thanks

#22 MatthewNg

    Newbie

  • Kontributors
  • Pip
  • 2 posts

Posted 27 May 2011 - 08:01 PM

View PostSwapnochari, on 19 May 2011 - 07:03 AM, said:

I want to print an specific cell of a table in a html page, you all r yalking abt printing the whole page. nac anybody suggest how to print specific area/cell of a table ??
thanks

Try using @media print
Attach it either:
<link rel="stylesheet" type="text/css" href="print.css" media="print" />  With the code below

or

<style>
@media print{
   *{
       display:none;
   }
   .printThis{  /* Might want to attach this on the td and its table */
       display:block;
   }
}
</style>


And in the body:

<body>
   <input type='button' onclick='window.print();'>
   <table class='printThis'>
       <tr>
           <td class='printThis'>
               My information to print
           </td>
           <td class=''>
               Do not print this text
           </td>
       </tr>
   </table>
</body>

"@media print" would be used once the html page is being printed. Everything would be display:none so that it will not show and only attaching a class "printThis" would show that cell of the table which is what you want.

Edited by MatthewNg, 27 May 2011 - 08:10 PM.


#23 Guest_Santosh_*

  • Guests

Posted 12 October 2011 - 06:19 AM

View Postcragllo, on 11 May 2005 - 04:22 PM, said:

A quick search, and I found this:

<script Language="Javascript">

/*
This script is written by Eric (Webcrawl@usa.net)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function printit(){  
if (window.print) {
    window.print();  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}
</script>

<script Language="Javascript">  
var NS = (navigator.appName == "Netscape");
var VERSION = parseInt(navigator.appVersion);
if (VERSION > 3) {
    document.write('<form><input type=button value="Print this Page" name="Print" onClick="printit()"></form>');        
}
</script>

All tyhe information you need is here, also gives a demo too: http://dynamicdrive....dex9/other1.htm

But while using this print function even the print gets printed on the paper. Can you please suggest my some other idea such that the print button doesn't come on the printed paper




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users