0

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) 
{
    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?

1
  • I left out the fact that there is a div with the id=print_div that displays the images. Commented Jul 13, 2011 at 5:27

1 Answer 1

6

Couldn't you just do:

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.