Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/409.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何将鼠标悬停在浏览器的“取消”按钮上?_Javascript_Html_Css - Fatal编程技术网

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

Javascript 如何将鼠标悬停在浏览器的“取消”按钮上?,javascript,html,css,Javascript,Html,Css,我试图在我的网站上填充一个初始屏幕,如果scroll pos在1-120之间,则使用以下JS代码填充 如果我想在悬停浏览器和选项卡的“取消”按钮上执行此操作,请建议应该做什么 如何阅读,原因$window.scrollTop;如果小于0,则不会返回任何内容 function setHeightToEmergencyContainer () { var getWindowHeight = $(window).height(); var setHeight

我试图在我的网站上填充一个初始屏幕,如果scroll pos在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
   }
});
希望这对你有帮助