Javascript print with out pop up
-
Hi, How to print only the string using javascript with out pop up. eg: string = "(table border='1')(tr)(td)Hello Javascript...(/td)(/tr)</table)" *(replace '(' and ')' with '<' and '>') I need to print the text string with a table and text "Hello Javascript...". with out pop up I don't want to print the entire page. Thankyou, YPKI
-
Hi, How to print only the string using javascript with out pop up. eg: string = "(table border='1')(tr)(td)Hello Javascript...(/td)(/tr)</table)" *(replace '(' and ')' with '<' and '>') I need to print the text string with a table and text "Hello Javascript...". with out pop up I don't want to print the entire page. Thankyou, YPKI
How do you mean print, to a physical printer or to be outputted to the page. If it is the latter you could use document.write(), trying to output to a printer is a bit more difficult but not impossible. To do this you could create a new iframe dynamically, point it nowhere and start writing to it with document.write(). All that is left then is calling the .print on that frame.
-
Hi, How to print only the string using javascript with out pop up. eg: string = "(table border='1')(tr)(td)Hello Javascript...(/td)(/tr)</table)" *(replace '(' and ')' with '<' and '>') I need to print the text string with a table and text "Hello Javascript...". with out pop up I don't want to print the entire page. Thankyou, YPKI
Hi, you shoud have a new document with your string and then fire the print event.
-
Hi, How to print only the string using javascript with out pop up. eg: string = "(table border='1')(tr)(td)Hello Javascript...(/td)(/tr)</table)" *(replace '(' and ')' with '<' and '>') I need to print the text string with a table and text "Hello Javascript...". with out pop up I don't want to print the entire page. Thankyou, YPKI
Give whatever element u wanna print this id "printMe". Include this script in your head tag:
var gAutoPrint = true;
function processPrint(){
if (document.getElementById != null){
var html = '<HTML>\n<HEAD>\n';
if (document.getElementsByTagName != null){
var headTags = document.getElementsByTagName("head");
if (headTags.length > 0) html += headTags[0].innerHTML;
}
html += '\n</HE' + 'AD>\n<BODY>\n';
var printReadyElem = document.getElementById("printMe");
if (printReadyElem != null) html += printReadyElem.innerHTML;
else{
alert("Error, no contents.");
return;
}
html += '\n</BO' + 'DY>\n</HT' + 'ML>';
var printWin = window.open("","processPrint");
printWin.document.open();
printWin.document.write(html);
printWin.document.close();
if (gAutoPrint) printWin.print();
} else alert("Browser not supported.");
}
Call the function
[Print](javascript:void(processPrint());)
Atul Kumar