我想编写一个JavaScript,使::当我将鼠标移到关闭的窗口和选项卡上时,它仅应在当时给我警报。我已经编写了该脚本,但是每当我将鼠标移到“最小化”,“向下还原”,“关闭”或将鼠标悬停在选项卡上时,该脚本就会执行。我希望逻辑仅在将鼠标悬停在关闭的窗口和选项卡上时执行。每当我将鼠标悬停在关闭的窗口/选项卡上时,都不应重复该操作。
<style>
.banner-text>div>.banner-link.link-highlight
{
display: none;
}
.booking-widget-home
{
background-image:url('https://www.chimp.in/content/dam/chimp/website/banner/target/12/upgrade-banner.jpg') !important;
}
.banner-title
{
color: white;
}
.banner-description
{
color: white;
}
.banner-link.link-highlight
{
border-radius: 10px;
}
.banner-text > p > span
{
bottom: -20px;
position: relative;
}
div.knowMore
{
display: block;
}
</style>
<script>
(function()
{
'use strict';
var cnt=6000;
function init()
{
if(typeof jQuery !="undefined")
{
windowClose();
}
else
{
cnt=cnt-500;
if(cnt>500)setTimeout(init,500);
}
}
var addEvent = function(obj, evt, fn)
{
if (obj.addEventListener)
{
obj.addEventListener(evt, fn, false);
}
else if (obj.attachEvent)
{
obj.attachEvent("on" + evt, fn);
}
};
addEvent(document, "mouseout", function(event)
{
event = event ? event : window.event;
var from = event.relatedTarget || event.toElement;
if ( (!from || from.nodeName == "HTML") && event.clientY <= 100 )
{
alert("Please Browse through website before exit!");
}
});
function windowClose()
{
some other logic ....
}
init();
})()
</script>