modal-on-exit feature

5 replies · opened Oct 25, 2023

SswwammpOct 25, 2023

Hi Semicolon,

I'd like to implement to my webshop an exit popup that shows up when user plans to leave the page.
I found your .modal-on-load feature (eg in modal-onload-subscribe.html), also found it in the functions.js:

		modal: function( element ){
			let settings = {
				element: element,
				default: '.modal-on-load',
				file: 'plugins.lightbox.js',
				error: 'plugins.lightbox.js: Plugin could not be loaded',
				execfn: 'SEMICOLON_modalInit',
				pluginfn: () => $().magnificPopup,
				trigger: 'pluginLightboxReady',
				class: 'has-plugin-lightbox'
			};

			SEMICOLON.initialize.functions( settings );
		},

I'm wondering if you had a similar easy-to-implement solution for exit popups, so I could include the modal with similar easy way, with adding a .modal-on-exit class.
If I need to add some code to my footers (instead of functions.js), that's also fine.

Currently I have the following code that triggers the event when user wants to leave the page.

jQuery(document).on('mouseleave', function(e) {
        if (e.clientY < 0) {
   		alert('show modal here');
        }
    });

I didn't update to Canvas 7 yet (still using Canvas 6.6.5) but would be great if you had some ideas how to implement it with JQuery and magnificPopup.

Many Thanks,
A.

SSemicolon WebSTAFFOct 26, 2023

Hello,

Modal on Exit is not supported by default and requires additional customizations. You can consider using something like this:
[ch_pre type="js"]jQuery(document).on('mouseleave', function(e) {
if (e.clientY < 0) {
jQuery('[href="#myModal1"]').magnificPopup('open');
}
});[/ch_pre]

This will definitely work fine. Hope this Helps!

Since, currently Customization related Support is not included with the License according to the Item Support Policy: https://themeforest.net/page/item_support_policy . You will need to manually code any additional customizations or Hire Us to help you out with Customizations.

Let us know if we can help you with anything else or if you find any further issues.

PS. You can only use One License of Canvas per Website else this will be against License Violation and Abuse, and will result in wrongful illegal usage under the Licensing Terms. You will need to Purchase another Regular License for each new website. We request you to comply.

SswwammpOct 26, 2023

Hi,

Thank you for your response. I will check the code I'm sure it will work perfectly.
PS: I am aware of limitations of the licence and I am genuinely using my licence on only one website - of course, additional licences will be purchased when other website will be built based on it.
Thanks,
A.

SSemicolon WebSTAFFOct 26, 2023

Very Happy to Help! :) And Thank You for the Clarifications.

Do let us know if we can help you with anything else.

SswwammpMar 21, 2025

Hello Semicolon,

Great to see you back!

I just getting back to this issue - the situation is that I plan to integrate the exit modal, but with ajax load.
It's based on the modal-onload-subscribe.html. The main html contains this:


ajax loaded content will come here

and also, all inner part of modal1 (incl background of modal, etc.) is loaded by ajax.

Main js code:

    document.addEventListener('mouseleave', function(e) {
	if (e.clientY  ((index):775:37)
    at HTMLDivElement. (

Any idea?

Thanks
A.

SSemicolon WebSTAFFMar 25, 2025

Hello,

Thanks for your Kind Patience! :)

Based on your codes, it appears that there should a Hidden Button somewhere on the Page which triggers this Modal in order to initialize this AJAX Modal as a Magnific Popup. Example:
[ch_pre]Inline Modal[/ch_pre]

Additionally, you can also consider this JS Code for triggering the Modal on Window Close but if the previous JS works with the above fix, then there is no need to change the JS Codes:
[ch_pre type="js"]window.addEventListener('beforeunload', function (e) {
e.preventDefault();
e.returnValue = '';
// Modal Codes
});[/ch_pre]

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard
modal-on-exit feature · Canvas Template Support