Uncaught TypeError: Unable to read undefined property document

I have the following function that works fine on several computers that I tested on. I tested this in Chrome, IE and Firefox without any problems. However, there is 1 specific PC (Chrome works) that throws this error "Uncaught TypeError: Unable to read the document" properties "undefined" in the line:

                win.document.write(data);

Maybe because win is null?

If so, why is this happening on this particular PC?

Are there any Chrome settings that need to be set?

Method:

    function viewReport() {
        console.info('generating event report');
        var frmData = $('#frmEventReport').serializeArray();
        var rptName = 'EventReport' + Math.floor((Math.random() * 100) + 1);
        console.info('generated random report name ' + rptName);
        $.ajax({
            //type: "GET",
            timeout: 120000,
            url: '@Url.Action("EventReport", "Reports")',
            data: frmData,
            success: function (data) {
                console.info('succesfully called back');
                var win = window.open('', rptName, '_blank');
                console.info('opening window');
                win.document.write(data);

            },
            error: function (x, y, z) {
                console.info(x + ' ' + y + ' ' + z);
            }
        });
    }
+4
source share
1 answer

Chrome? , , win undefined

+10

All Articles