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

时间:2015-06-12 13:11:52

标签: javascript html css

我正在尝试在我的网站上填充启动画面,并且如果滚动位置在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%"}); } 不会返回任何内容。

{{1}}

1 个答案:

答案 0 :(得分:4)

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

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

用于浏览器悬停使用:

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

希望这会对你有所帮助。