Nitin Kabra
Nitin Kabra

Reputation: 3226

Printing html popup window using javascript

how do i print a html page which is getting opened in a popup ?

what I tried is :

function printFile() {
        var w = window.open('test.htm', 'name', 'width=200,height=200');
        w.focus();
        w.print();
    }

but the above code always prints about:blank.

Upvotes: 2

Views: 4925

Answers (2)

Greendrake
Greendrake

Reputation: 3734

You have to wait for the window to load:

function printFile() {
        var w = window.open('test.htm', 'name', 'width=200,height=200');
        w.onload = w.print;
        w.focus();
    }

Upvotes: 2

Falguni Panchal
Falguni Panchal

Reputation: 8981

check your test.htm page it should be in same folder

i have check your code it's run perfectly.

Upvotes: 0

Related Questions