Reputation: 899
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
Reputation: 1
Try frames_array[frame_name].document.execCommand('print', false, null);
Upvotes: -1
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
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