js笔记

防止使用window.pen()方法时,浏览器阻止窗口弹出:

方法一:
var a = $("<a href='http://www.baidu.com' target='_blank'>Apple</a>").get(0);
var e = document.createEvent('MouseEvents');
e.initEvent('click', true, true);
a.dispatchEvent(e);

方法二:
var sFeatures = "dialogHeight=" + screen.availHeight + ";dialogWidth=" + screen.availWidth + ";dialogLeft=0;dialogTop=0";
var returnValue = window.showModalDialog("about:blank", "", sFeatures);

你可能感兴趣的:(JavaScript)