Function expected error when window is closed

Hi All,

i am getting the following error when i try to close a window opened through client side before print dialog appears.
Error: function expected

I am opening a window and print dialog simultaneously, print dialog is taking few seconds to open after the window. before the print dialog is opened when i close the window i am getting the error.
below is my code,

function OnClick() {

        var a = window.open('', '', 'width=300,height=300');
        a.document.open("text/html");

        a.document.close();
        a.print();
    }

<asp:Button ID=“btn” runat=“server” Text=“Click” OnClientClick=“OnClick()”/>

Can any one please help me how to resolve this issue.

Thanks you,

Jai

onClick is already a javascript function, that might cause an issue.

Thank you SpikeZ for your reply, even if i change the function name still its an issue. Issue is coming when i close the popup before print window is displayed.


function OnClick()
{

            var a = window.open('', '', 'width=300,height=300');
            a.document.open("text/html");

            // presumably you're writing content here

            a.document.close();

            [B][COLOR="#0000FF"]if( !a.closed )[/COLOR][/B]
              a.print();
}


Thank you Logic Ali, i tried as you mentioned above but no use, still i am getting error.

Thank you once again.

Where do you see this error message and what data are you writing to the window?

in the popup we are loading some content to be printed.

please find the error image attached.