开发者

Can I Modify this Javascript to Print Images from Div?

开发者 https://www.devze.com 2023-03-19 17:02 出处:网络
I have a div in my page layout that I would like to print.I have worked through some sample code on how to do this and come up with the following:

I have a div in my page layout that I would like to print. I have worked through some sample code on how to do this and come up with the following:

<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) 
{
    v开发者_Go百科ar mywindow = window.open('', 'print_div', 'height=400,width=600');
    mywindow.document.write('<html><head><title>Print Window</title>');
    mywindow.document.write('</head><body >');
    mywindow.document.write(data);
    mywindow.document.write('</body></html>');
    mywindow.document.close();
    mywindow.print();
    return true;
}

</script>

Then in the body of the HTML I place the following button:

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

This works great for creating a quick print of the text based content on the page, but what I need it to do is print out the images that are being displayed on the page as well. Can I alter this script to do this?


Couldn't you just do:

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

Reference: http://api.jquery.com/html/

0

精彩评论

暂无评论...
验证码 换一张
取 消