why my print doesn't work?

Posted by udaya on Stack Overflow See other posts from Stack Overflow or by udaya
Published on 2010-03-25T05:27:06Z Indexed on 2010/03/25 5:33 UTC
Read the original article Hit count: 538

Filed under:
|

hi In this below program i am printing the contents of the div when i click the print button i am receiving an alert message printer error not available why it is so

<html>
<head>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.1.min.js" > </script> 
<script type="text/javascript">

    function PrintElem(elem)
    {
        Popup($(elem).text());
    }

    function Popup(data) 
    {
        var mywindow = window.open('', 'my div', 'height=400,width=600');
        mywindow.document.write('<html><head><title>my div</title>');
        /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
        mywindow.document.write('</head><body >');
        mywindow.document.write(data);
        mywindow.document.write('</body></html>');
        mywindow.document.close();
        mywindow.print();
        return true;
    }

</script>
</head>
<body>

<div id="mydiv">
    This will be printed. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a quam at nibh adipiscing interdum. Nulla vitae accumsan ante. 
</div>


<input type="button" value="Print Div" onclick="PrintElem('#mydiv')" />

</body>
</html>

© Stack Overflow or respective owner

Related posts about html

Related posts about JavaScript