Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Eero Hermlin

    (@eero-hermlin)

    Hi

    To avoid abuse, all major browsers allow only very limited intervention to browser navigation, I guess with window.onbeforeunload you can stop leaving page only if confirm() is used. Without confirm() visitor even doesn’t have time to notice what happened in window before it closed. Fortunately or unfortunately something like event.preventDefault() together with onbeforeunload is not possible.

    What you can do is to show box when mouse leaves window, e.g. when visitor is perhaps thinking to close tab, to activate another tab, to use back button etc. For that, open Scrollbox editor in “Text” mode and append to html following script:

    <script type="text/javascript">jQuery(document).mouseleave(function() {$DGD.showBox($DGD.getBoxById('dgd_scrollbox-XXX'), true);});</script>

    NB!

    • In place of dgd_scrollbox-XXX use your actual scrollbox div element id, what you can discover from page source.
    • Scripts in WordPress editor are good to write into one row, because standard editor tends to add a “p” tag to empty lines and this would spoil the script.
    • .mouseleave() fires also when user is moving mouse over to right scrollbar.
    Thread Starter champ1on

    (@champ1on)

    Your instructions are unclear. Scroll triggered box stopped working

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to show the box when the visitor intends to leave the page?’ is closed to new replies.