External URL Notification Popup

In this tutorial I will show you a free and easy way to have a browser popup notification when a user clicks on an external link on your website.

I will be using Elementor Pro to pull off this effect, but since it’s just simple JavaScript you can use this code on any website.

Timestamps:

  • 0:00 Introduction
  • 1:38 Tutorial Begins

Credits:
https://codepen.io/baykodnet/pen/pGPPeZ

JavaScript Code:

				
					<script>
jQuery(function($){
    $('a').on('click', function() {
   if ( this.host !== window.location.host ) {
      var thisHrefHere = this.href;
      if ( window.confirm('Warning! You are now leaving this website. You clicked on the external URL: '+thisHrefHere+'') ) {        
      }else {         
         return false;
      }    
   }
});
});
</script>
				
			

Free Brand Messaging Worksheet

Define Your Voice and Connect with Your Audience

More Free Resources

Let's Work Together

Big ideas start with a quick chat. Let’s talk!