Tagged: ,

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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

    #320283

    Hi 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,
    Ismael

    #320537

    Ismael,

    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 Haswell

    #320886

    Hi!

    Thank you for the update.

    Your editor is converting the symbols automatically. Please get the code here: http://pastebin.com/XCnz5nWQ

    Best regards,
    Ismael

    #321390

    Thanks 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!!
    John

    #321580

    Hi 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,
    Josue

    #321621

    Hi 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!
    John

    #321622

    Nevermind guys! I figured out what I did pasting it incorrectly! It’s working perfectly. Thanks so much for the help!! Life savers!

    – John

    #321633

    You are welcome John, glad we could help :)

    Regards,
    Josue

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Pop-up when exiting site through external link’ is closed to new replies.