I am working on a piece of code but i am not able to get it to work on mobile because there is no mouseout event .. i am looking to convert this code into something that works on mobile .. if a mobile user goes to another window or tab on his mobile phone from the one containing the div , I wish to hide the div permanently.
How do I achieve similar working code on mobile ?
<script type="text/javascript">
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") {
document.getElementById('ControlCode').style.display = "none";
document.getElementById('ControlCode').style.visibility = "hidden";
}
});
});
</script>