gpt4 book ai didi

javascript - 如何将鼠标悬停在浏览器的取消按钮上?

转载 作者:行者123 更新时间:2023-11-29 18:06:25 25 4
gpt4 key购买 nike

我正在尝试在我的网站上填充启动画面,如果滚动位置在 1-120 之间,它就会填充,使用以下 JS 代码。

如果我想在悬停浏览器和选项卡的取消按钮上执行此操作,请建议应该怎么做?

如何读取它,因为 $(window).scrollTop(); 如果小于 0 则不会返回任何内容。

      function setHeightToEmergencyContainer () {
var getWindowHeight = $(window).height();
var setHeight = (getWindowHeight - 123)/2;
}
setHeightToEmergencyContainer();
$(window).resize(function() {
setHeightToEmergencyContainer();
});
function addEvent(obj, evt, fn) {
if (obj.addEventListener) {
obj.addEventListener(evt, fn, false);
}
else if (obj.attachEvent) {
obj.attachEvent("on" + evt, fn);
}
}
addEvent(window,"load",function(e) {
addEvent(document, "mouseout", function(e) {
e = e ? e : window.event;
var from = e.relatedTarget || e.toElement;
if (!from || from.nodeName == "HTML") {
// stop your drag event here
// for now we can just use an alert
setHeightToEmergencyContainer();
var scroll = $(window).scrollTop();
console.log("scroll pos :: "+scroll);
if(scroll > 0 && scroll <= 120){
console.log("show popup "+scroll);

$(".tso_pop-container").css({"width":"1366px","height":"700px","overflow":"auto","right":"-296px","top":"106px"});
}
//$.cookie("dontShowUrgencyContainer","yes");

}
});
addEvent(document, "mouseover", function() {
$(".tso_pop-container").css({"width":"0px","height":"0px","overflow":"hidden","right":"50%","top":"50%"});
});
});

//}

window.onblur = function(event) {
$(".tso_pop-container").css({"width":"0px","height":"0px","overflow":"hidden","right":"50%","top":"50%"});
}

最佳答案

首先获取文档使用的滚动位置:

$('body').scrollTop() // webkit
$('html').scrollTop() // moz

对于浏览器悬停使用:

$(window).mouseenter(function(){
var stop = $('html').scrollTop() == 0 ? $('body').scrollTop() : $('html').scrollTop()
if(stop <= 120){
// your code
}
});

希望对你有帮助。

关于javascript - 如何将鼠标悬停在浏览器的取消按钮上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30803981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com