I want to write a javascript such that :: When I bring the mouse over the close window and tab, it should give me an alert at that time only. I have written that script but it is executing whenever I bring the mouse over the "minimize", "restore down", "close", or whenever I hover the mouse over the tab. I want the logic to execute only on first mouse hover over close window and tab. It should not repeat whenever I hover the mouse over the close window/tab.
<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>