Facebook Twitter Gplus LinkedIn YouTube Google Maps RSS
Home Technical JavaScript..Print contents in a DIV
formats

JavaScript..Print contents in a DIV

PRINT WATEVER YOU WANT IN A DIV, ON A BUTTON CLICK.

Aaron says “Create a div around the content you want to print”.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

ButtonPrint.Attributes.Add(“onclick”, “javascript:CallPrint(‘divPrint’);”)
end sub

<script language=”javascript”>
function CallPrint(strid) {
var prtContent = document.getElementById(strid);
var strOldOne = prtContent.innerHTML;
var WinPrint = window.open(”, ”, ‘left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0′);
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML = strOldOne;
}
</script>

Strid should be the ID of the DIV.

Dont forget runat=”Server”

 
Tags: ,
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy this password:

* Type or paste password here:

12,872 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© All rights reserved to Cyberbrutus. 2012
credit

Switch to our mobile site