Popup trigger onload window

Bonjour.

I need to trigger a popup when the mouse leaves the window. I was inspired by the pinegrow doc
I think it comes from the jquery script that I don’t understand all :wink:

<script data-toggle="modal" data-target="#exit">
      function openModal() {
        $(window).bind('unload').modal();
  };
</script>

Thanks for your help !

What you want can be little annoying to the users, so think about using it.

But to let you know that we can use PG Interactions in more advance way as well.

In the document you mentioned, says to apply script as below

<script>
  function openModal() {
    $('#thumb_one').modal();
  };
</script>

So first place this script somewhere in your page or to the linked JS file.

This means if we can run openModal function our modal will popup. We can do it with some more custom JS but we use PG Interaction so that we don’t have to write any more code.

  • For this you can add an Interaction on the body
  • On Trigger go to Mouse only and select Mouseleave
    (Here I’m selecting Mouse only because I’m not targeting touch device for this interaction because it will be popping all the time, you can test that yourself)
  • Now click on Edit Animation, on the timeline editor add a transition and select Set
  • Set Position as 0
  • Now click on Add property > Interactions and select On complete
  • Now for On complete enter the function name openModal

Now hover over your page/body and the hover out of it and your modal should popup.

Please try this and let me know if you encounter anything.

OK, thank you very much for these insights.
You are right. It is not very pleasant for the user, but it is a request…

I have two problems:

  • I selecting Mouse only but it will be popping all onclick in the body
  • The popup does not open in Wordpress theme

Thanks for your support

On Trigger if you’ve chosen Mouse only and selected Mouseleave then it should act on mouse leave. If it is acting on click then please check your settings.

And about popup not opening on WordPress, I cannot be very sure but if you’ve exported WP theme properly it will act in the same way as it works on normal HTML. Exporting shouldn’t change anything on the interactions unless if there is change is your target element on the WordPress side.