Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #398761

    Is there anyway of adding some ALERT TEXT to an image link??

    I came across this thread which showed how to do with with a simple html text link. But I want to know if the same is possible with an image link.

    https://kriesi.at/support/topic/pop-up-when-exiting-site-through-external-link/

    You set the image link manually but it doesn’t seem to use HTML text and just accepts the actual web address.

    #398869

    Hey mecdesign!

    Please give a class to your IMG tag or A tag containing IMG element as Ismael suggested here – https://kriesi.at/support/topic/pop-up-when-exiting-site-through-external-link/#post-320283
    Then change the code to following one and add it to Functions.php file in Appearance > Editor

    function add_custom_script(){
    ?>
    <script>
    jQuery(window).load(function(){
    	jQuery('a.external-link img, .external-link a img').click(function() {
    		alert("You're going to a better place.");
    	});
    });
    </script>
    <?php
    }
    add_action('wp_head', 'add_custom_script');

    Cheers!
    Yigit

    #399634

    Ok will try

    • This reply was modified 9 years, 9 months ago by mecdesign.
    #399698

    Hello Yigit,

    well after an eventful few hours of trying that and then the functions.php failing on me and my website going blank and me reloading the original functions.php file I managed to get it working….

    We use this ALERT TEXT in order to give information about a price list before it opening in another window a pdf.

    The only problem is that I will need the same when I create the German version. I will also need German text. So text that shows on one side and another text that shows in the other language.

    Any ideas?

    #400165

    Hi!

    I think it would work with this plugin: WPML

    Regards,
    Andy

    #400618

    Well Im using a language tool ok with the Enfold Theme without any problems and the code that I am having to type into the functions.php so I presumed there is no way to add this in anywhere.

    #400628

    Hi!

    Please change the code to following one

    function add_custom_script(){
     if (ICL_LANGUAGE_CODE == 'de') {
    ?>
    <script>
    jQuery(window).load(function(){
    	jQuery('a.external-link img, .external-link a img').click(function() {
    		alert("Hallo! You're going to a better place in German.");
    	});
    });
    </script>
    <?php
    }
    else {
    ?>
    <script>
    jQuery(window).load(function(){
    	jQuery('a.external-link img, .external-link a img').click(function() {
    		alert("You're going to a better place.");
    	});
    });
    </script>
    <?php
    }
    add_action('wp_head', 'add_custom_script');

    Cheers!
    Yigit

    #432654

    Hello. Sorry Ive just gotten around to trying this with the language thing and its not having it.
    When I save it, it then crashes the php and I have to upload the original.

    It works ok when i have just the english version but there is something that it doesnt like with the extra stuff.

    #432656
    This reply has been marked as private.
    #432859

    Hey!

    Can you please post the link to your website where we can see the alert?

    Regards,
    Yigit

    #432892
    This reply has been marked as private.
    #432907

    Hi!

    Can you please try changing your code to following one

    function add_custom_script(){
    ?>
    <script>
    jQuery(window).load(function(){
    	jQuery('html[lang='de-DE'] a.external-link img,html[lang='de-DE'] .external-link a img').click(function() {
    		alert("You're going to a better place in German");
    	});
    	jQuery('html[lang='en-GB'] a.external-link img,html[lang='en-GB'] .external-link a img').click(function() {
    		alert("You're going to a better place in English");
    	});
    });
    </script>
    <?php
    }
    add_action('wp_head', 'add_custom_script');

    Regards,
    Yigit

    #529693

    This initially worked and now it has stopped working. Any suggestions? Here is what was used from previous threads…

    function add_custom_script(){
    ?>
    <script>
    jQuery(window).load(function(){
    	jQuery('a.external-link').click(function() {
    		alert("A new window will open as you leave Care N' Care's website. To return to this page, close the new window.");
    	});
    });
    </script>
    <?php
    }
    add_action('wp_head', 'add_custom_script');
    
    #530256

    Hi!


    @jamman
    Please start a new thread, post login credentials privately and point out your button. If you post them here, OP would be able to see your private content.

    Cheers!
    Yigit

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.