I have the following function, which works fine on a few PCs that I've tested on. I've tested this on Chrome, IE & Firefox with no issues. However, there's 1 particular PC (running Chrome), that throws this error "Uncaught TypeError: Cannot read property 'document' of undefined" on the line:
我有以下功能,可以在我测试的几台PC上正常工作。我已经在Chrome,IE和Firefox上对此进行了测试,没有任何问题。但是,有一个特定的PC(运行Chrome),在该行上抛出此错误“Uncaught TypeError:无法读取未定义的属性'文档':
win.document.write(data);
Could it be because win is null?
可能是因为胜利是空的吗?
If so, why is this the case on this particular PC?
如果是这样,为什么在这台特定的PC上就是这种情况?
Is there some Chrome settings that needs to be set?
是否需要设置一些Chrome设置?
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);
}
});
}
1 个解决方案
#1
13
Are popups enabled on that PC's Chrome? If they're not then the new window cannot be created hence win
is undefined
是否在该PC的Chrome上启用了弹出窗口?如果它们不是那么新的窗口就无法创建,因此win未定义
#1
13
Are popups enabled on that PC's Chrome? If they're not then the new window cannot be created hence win
is undefined
是否在该PC的Chrome上启用了弹出窗口?如果它们不是那么新的窗口就无法创建,因此win未定义