Printing the content inside the div tag
I want to print the content in the a div tag. I have tried that somewhre i read of copying the content in the divtag to a window object. And print that new window. But in that it is opening a new window. But i dont want a new window to be opened.
The code i refered is as follows
function printSpecial()
{
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</HEAD>\n\n';
var printReadyElem = document.getElementById("printReady");
if (printReadyElem != null)
{
html += printReadyElem.innerHTML;
}
else
{
alert("Could not find the printReady function");
return;
}
html += '\n</BODY>\n</HTML>';
var printWin = window.open("","printSpecial");
printWin.document.open();
printWin.document.write(html);
if (gAutoPrint)
{
printWin.print();
}
}
else
{
alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
}
}
Can any one suggest a better way
Pooja
|