Print html page using window.open
Hi,
I am using window.open() method for client side printing of html pages. I am able to print one html page at a time but not more than one page. Please look at the below java script code snippet:
function combp1() {
var x = new Array(3)
x[0] = "hi how are you <a href='http://google.com'>google</a> "
x[1] = "whats up "
x[2] = "be happy and google (: <img src ='http://www.google.com/images/logo.gif'>"
var asdf = "<html><body onload='javascript: window.print();'>"
for (var i = 0; i < x.length; i++) {
asdf = asdf + x[i]
}
asdf = asdf + "</body></html>"
document.write(asdf)
document.close()
}
function combp2() {
var x1 = new Array(3)
x1[0] = "hi manish "
x1[1] = "whats up "
var asdf1 = "<html><body onload='javascript: window.print();'>"
for (var i = 0; i < x1.length; i++) {
asdf1 = asdf1 + x1[i]
}
asdf1 = asdf1 + "</body></html>"
document.write(asdf1)
document.close()
}
function printall()
{
combp1()
combp2()
}
</script>
Here two methods combp1 and combp2 having two different contents and printall() method call both of the method simultaneoulsy.
OK, Now the time to call printall()
<input type ="button" value ="print all" onclick ="printall()"/>
But only one method combp1() is calling and able to print only its contents.
How would I print the multiple pages.
Pleas guide me.
Thanks,
Manish
|