• If I have an external link that contains the site’s url in a parameter, the default css selector prevents the Exit Notifier popup from displaying. Is there a way to still make the popup display?

    For example, this url:
    https://www.google.com/calendar/render?details=Event:https://example.com/event

    will still be blocked because “example.com” is in the url. But since the link takes the user away from the site, I’d still like the popup to appear. Basically, Exit Notifier should only consider the domain of the url (the part before the question mark or hash sign), not the full url.

    Is this possible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mreall

    (@mreall)

    Here’s a possible solution. In assets/js/frontend.js in the jQuery(document).ready() function (around line 440), find the following line:

    jQuery(select_external).addClass('exitNotifierLink');
    

    Then, ABOVE that line, add the following code:

    jQuery('a').each(function () {
    	const url = $(this).attr('href');
    	try {
    		const { hostname } = new URL(url);
    		$(this).attr('exitnotifierdomain', hostname);
    	} catch (err) { /* Do nothing */ }
    });

    This code will add a new attribute exitnotifierdomain to all links that contain just the domain of the external link. Then, for those who need this functionality, we can update the selector in the admin backend (on the “Anchor Behavior” tab) as follows:
    a[href*="//"]:not([exitnotifierdomain*="example.com"])

    • This reply was modified 3 years, 3 months ago by mreall.
    • This reply was modified 3 years, 3 months ago by mreall.
    • This reply was modified 3 years, 3 months ago by mreall.
    Plugin Author Curtis V. Schleich

    (@cvscvstechcom)

    Thanks so much, @mreall! I will definitely include this or something like it in my next update.

    Very nice workaround to an issue that I know has been a problem before.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Doesn’t work if domain is in URL parameter’ is closed to new replies.