Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling print() on a frame in javascript hangs IE 8 browser

I want to print a particular frame in an array indexed by name. I am using the following code:

var frame_name = "abc"; 
frames_array[frame_name].focus(); 
frames_array[frame_name].print();

When it executes print() statement in IE8, it hangs. This piece of code works correctly in Firefox, Chrome and IE9.

I tried frames_array[frame_name].document.close() but it did not change anything. Is there a solution to this problem?

like image 945
azaveri7 Avatar asked Feb 03 '26 11:02

azaveri7


1 Answers

Try like this function.It will work.

function printDiv() {
 var divToPrint = document.getElementById('printArea');
    newWin.document.write(divToPrint.innerHTML)
    newWin.document.close();
    newWin.focus();
    newWin.print();
    newWin.close();

}
like image 151
Amrendra Avatar answered Feb 05 '26 00:02

Amrendra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!