我正在使用window.open打开我的PDF文件。以下是我的代码。
各种浏览器的反应:
function open_page(url, name, features) {
var win = window.open(url,
(name == null ? 'page' : 'test'),
(features == null ? 'menubar=1,toolbar=1,scrollbars=1,width=1024,height=768,resizable=1' : features));
win.focus();
if (win == null) {
alert('Not open');
} else {
document.isUnloading = false;
console.log("#2");
}
}
试过以下内容,但仍然没有在IE中工作。我将tge文档集中在第3次点击,第5次和第7次等等。不确定为什么它只能用于替代点击。
function open_page(url, name, features) {
alert("1"+win);
if (win == null) {
console.log("#1");
win = open(url, (name == null ? 'page' : 'test'), (features == null ? 'menubar=1,toolbar=yes,scrollbars=yes,top=500,left=500,width=1024,height=768,resizable=yes' : features));
}
else if (isIE()) {
console.log("#2");
win.close();
alert(win);
win = open(url, (name == null ? 'page' : 'test'), (features == null ? 'menubar=1,toolbar=yes,scrollbars=yes, top=500,left=500,width=1024,height=768,resizable=yes' : features));
}
else {
console.log("#3");
window.location.href = url;
win.focus();
}