admin管理员组文章数量:1390204
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 e up with the following:
<script type="text/javascript" src=".3.1.min.js" > </script>
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).text());
}
function Popup(data)
{
var 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?
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 e up with the following:
<script type="text/javascript" src="http://jqueryjs.googlecode./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('', '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?
Share Improve this question asked Jul 13, 2011 at 5:25 codacopiacodacopia 2,5119 gold badges41 silver badges59 bronze badges 1- I left out the fact that there is a div with the id=print_div that displays the images. – codacopia Commented Jul 13, 2011 at 5:27
1 Answer
Reset to default 6Couldn't you just do:
function PrintElem(elem)
{
Popup($(elem).html());
}
Reference: http://api.jquery./html/
本文标签: jqueryCan I Modify this Javascript to Print Images from DivStack Overflow
版权声明:本文标题:jquery - Can I Modify this Javascript to Print Images from Div? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744658521a2618101.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论