azaveri7
azaveri7

Reputation: 899

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?

Upvotes: 3

Views: 1076

Answers (3)

user3546840
user3546840

Reputation: 1

Try frames_array[frame_name].document.execCommand('print', false, null);

Upvotes: -1

azaveri7
azaveri7

Reputation: 899

even this did not worked. I guess the problem is that I am not opening a new window for printing but directly print the frame on which button is present.

Upvotes: 0

Amrendra
Amrendra

Reputation: 2077

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();

}

Upvotes: 3

Related Questions