0

I've been trying to find a good reference on how to create a popup when someone leaves your browser and I'm not having any luck. I'm trying to set it up when the mouse leaves the browser, not on exiting the page. Can someone point me in the right direction?

It's just a message box i'm trying to display when the mouse leaves the browser. I've tried the .mouseleave() function but it appears when I go to the scroll bar and I want to prevent that.

Military911
  • 35
  • 1
  • 9
  • I think you can get your answer here: http://stackoverflow.com/questions/923299/how-can-i-detect-when-the-mouse-leaves-the-window – Gus de Boer Oct 29 '14 at 23:03

2 Answers2

1

Put this in your html tag:

...
<html onmouseout = "mouseOutOfWindow()">
...

And then write this for the mouseOutOfWindow function:

mouseOutOfWindow(){

window.alert("alertText"); //You can use an alert box, or any other kind of popup.

}

Good Luck!

DripDrop
  • 994
  • 1
  • 9
  • 18
1

Just simply do

<body onMouseout="bye()">

Javascript

<script>
function bye() {
alert("Goodbye!")
}
</script>
Provision
  • 273
  • 1
  • 10
  • thank you but my script works when leaving the body. my issue is when I go to the scrollbar on the right, the popup shows and I don't want that. I want them to be able to use the scrollbar without the message popping up. I also tried $(window).mouseleave() but it's giving me the same issue. – Military911 Oct 30 '14 at 15:32