SarwarPro Posted January 4, 2023 Share Posted January 4, 2023 Hello, I have a site on Squrespace. I have added an extenal link as a menu item. So, if anybody click on that menu item, he will visit to the external link. But I want that, if anybody click on that link, first he will get a warning message like "Leaving the current site" and then if he clicks on okay the will visit the linked external site. Is it possible that I can do in the website? Thank You Link to comment
tuanphan Posted January 5, 2023 Share Posted January 5, 2023 Try Settings > Advanced > Code Injection > Footer <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> <script> $('a').on('click', function() { if ( this.host !== window.location.host ) { var thisHrefHere = this.href; if ( window.confirm("Hey! Warning. U Click another url: "+thisHrefHere+"") ) { console.log('Click true and redirecting'); }else { console.log('Click false and no redirect'); return false; } } }); </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment