-
AuthorPosts
-
February 19, 2015 at 11:02 am #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.
February 19, 2015 at 1:42 pm #398869Hey 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 > Editorfunction 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!
YigitFebruary 20, 2015 at 2:18 pm #399634Ok will try
- This reply was modified 9 years, 10 months ago by mecdesign.
February 20, 2015 at 3:30 pm #399698Hello 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?
February 22, 2015 at 2:27 am #400165February 23, 2015 at 1:19 pm #400618Well 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.
February 23, 2015 at 1:30 pm #400628Hi!
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!
YigitApril 22, 2015 at 9:53 am #432654Hello. 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.
April 22, 2015 at 9:54 am #432656This reply has been marked as private.April 22, 2015 at 3:22 pm #432859Hey!
Can you please post the link to your website where we can see the alert?
Regards,
YigitApril 22, 2015 at 4:02 pm #432892This reply has been marked as private.April 22, 2015 at 4:14 pm #432907Hi!
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,
YigitNovember 4, 2015 at 1:33 am #529693This 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');
November 4, 2015 at 5:21 pm #530256 -
AuthorPosts
- You must be logged in to reply to this topic.