我正在尝试使此代码正常工作,但由于某些原因,if语句适用于:
document.addEventListener("scroll",under);
function under() {
if (window.screenY > 20) {
console.log("over 20");
var a = document.createElement("a"),
e = document.createEvent("MouseEvents");
a.href = "http://google.com"; //the URL of 'popup' tab
e.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, true, false, false, true, 0, null);
a.dispatchEvent(e);
document.removeEventListener("scroll", under);
}
};