The popup when exiting a site help

Hello there !
it was working only on Chrome on my side.
This is a way to make it work on Safari, Firefox & Chrome.
It works a bit differently, the pop up shows if you’re trying to escape from any side of the window…

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>


function addEvent(obj, evt, fn) {
    if (obj.addEventListener) {
        obj.addEventListener(evt, fn, false);
    }
    else if (obj.attachEvent) {
        obj.attachEvent("on" + evt, fn);
    }
}
// Trigger
addEvent(document, 'mouseout', function(evt) {

    if (evt.toElement == null && evt.relatedTarget == null ) {
        $('#exit-popup').slideDown();
    };

});

// Close the pop up
$('#exit-popup-cross').click(function(){
    $('#exit-popup').slideUp();
});

</script>