-
AuthorPosts
-
September 16, 2014 at 8:02 pm #320115
Good Afternoon!
I’m not sure if this is something that is possible through the theme and not an external plugin (haven’t been able to find one yet), but I’m trying to have a legal disclaimer appear when exiting the site through two specific external links. This is for a pharmecutical site that needs to give them message to ensure people know they aren’t on their site anymore.
Is this something that could be created using the Light Box functionality? It would just need to be text or an image that appeared before being redirected from the site.
The problem is it is only needed for two specific external links, not all of them on the site, and one of them happens to be in the main menu. Didn’t know if Enfold could pull something like this off. If not, does anyone have suggestions. Much appreciated!!
– John Haswell
September 17, 2014 at 4:55 am #320283Hi jnhaswell!
Thank you for using Enfold.
Do you mean some kind of alert message? You can add a unique class or selector on the link code. Like this for example:
<a class="external-link" href="http://www.google.com">Click Here</a>
Edit functions.php, add this at the very bottom:
function add_custom_script(){ ?> <script> jQuery(window).load(function(){ jQuery('a.external-link').click(function() { alert("You're going to a better place."); }); }); </script> <?php } add_action('wp_head', 'add_custom_script');
Change the alert message.
Regards,
IsmaelSeptember 17, 2014 at 3:19 pm #320537Ismael,
Thanks for the follow-up! This looks like exactly what I need, but upon adding the code to the bottom of the functions.php, I get a syntax error that crashes the site? Here’s a screenshot of where I put it and the lines that are getting errors. Any reason why this would be happening – I’m certainly not an expert with PHP unfortunately.
https://dl.dropboxusercontent.com/u/31251495/functions-error.jpg
Thanks again for the assistance!
– John HaswellSeptember 18, 2014 at 5:40 am #320886Hi!
Thank you for the update.
Your editor is converting the symbols automatically. Please get the code here: http://pastebin.com/XCnz5nWQ
Best regards,
IsmaelSeptember 18, 2014 at 6:53 pm #321390Thanks Ismael! Got it working for in posts/pages, but still having a little difficulty with the main menu. I’ve gone into the Appearance/Menus tab and made the option for “CSS Classes” available. I’ve put in “external-link” as the class. What am I missing on that end?
Thanks!!
JohnSeptember 18, 2014 at 11:49 pm #321580Hi John!
Use this code instead:
function add_custom_script(){ ?> <script> jQuery(window).load(function(){ jQuery('a.external-link, .external-link a').click(function() { alert("You're going to a better place."); }); }); </script> <?php } add_action('wp_head', 'add_custom_script');
Regards,
JosueSeptember 19, 2014 at 2:52 am #321621Hi Josue,
I’m getting an error: “PHP Parse error: syntax error, unexpected ‘?’ in E:\domains\instaglucose.com\wwwroot\wp-content\themes\enfold\functions.php on line 486”
Put the code through http://pastebin.com/, but still getting the error? Did I add something incorrectly?
Thanks!
JohnSeptember 19, 2014 at 2:53 am #321622Nevermind guys! I figured out what I did pasting it incorrectly! It’s working perfectly. Thanks so much for the help!! Life savers!
– John
September 19, 2014 at 3:37 am #321633You are welcome John, glad we could help :)
Regards,
Josue -
AuthorPosts
- The topic ‘Pop-up when exiting site through external link’ is closed to new replies.