• Hello,

    I’ve been trying everything in order to add a simple onclick event here and there in some pages and posts. What I need to add is this:

    <a style="cursor:pointer;" onclick="javascript: alert('Various text according to situation');">*</a>

    If you check the home page or the posts in my website, you will see asterisks with disclaimers which need to be there by law. Of course everytime I edit the page, the code gets stripped. What can I use instead of that?

    Thanks

    https://www.phylnex.com/

Viewing 9 replies - 16 through 24 (of 24 total)
  • Thread Starter TabyP

    (@tabyp)

    Also, for different statements I need to use different disclaimers but still using an asterisk. That’s why I was using that line of code which, let’s be honest, should work.

    Thread Starter TabyP

    (@tabyp)

    Aaaahhhh…. thanks for explaining… ?? Let me try

    Thread Starter TabyP

    (@tabyp)

    Okay now, :)… sorry to bug you again.

    If you try here https://www.phylnex.com/let-me-tell-you-my-story/
    You will see toward the bottom of the post that I have inserted the asterisks… Click on one, the popup opens, brilliant…but when you close it, it move the page to the top which can be quite annoying. Can I use the nohref attribute instead of href=”#”?

    Thread Starter TabyP

    (@tabyp)

    Also the first two asterisks work, then the rest don’t. Question. Are the following okay?

    jQuery(document).ready(function($) {
    
     $('#testimonial').click(function() {
      alert('Any testimonial is unique to the individual and actual results may vary.');
     });
    
    });
    
    jQuery(document).ready(function($) {
    
     $('#disclaimer').click(function() {
      alert('These statements have not been evaluated by the Food and Drug Administration. This product is not intended to diagnose, treat, cure, or prevent any disease. This article is for informational purposes only. See a professional health care provider if you are in need of medical care. This article is not a substitute for medical care. ');
     });
    
    });

    And then wherever I need, in multiple occasions, I use :

    <a style="cursor:pointer;" nohref id="disclaimer">*</a>
    or
    <a style="cursor:pointer;" nohref id="testimonial">*</a>
    ?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Click on one, the popup opens, brilliant…but when you close it, it move the page to the top which can be quite annoying

    You could do things like disable the behaviour with the href, like so (preventDefault):

    jQuery(document).ready(function($) {
    
     $('#that-link').click(function(event) {
      event.preventDefault();
      alert('Various text according to situation');
     });
    
    });

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The disclaimer seems to work for me

    Thread Starter TabyP

    (@tabyp)

    Yes the first two work. But try the asterisk where it says

    and the pain would vanish along with the stones. It was amazing how quickly the pain went away and how quickly, easily and pain-free the stones were passing.*

    It doesn’t do anything

    Thread Starter TabyP

    (@tabyp)

    How about (maybe that would be easier) If I add a Javascript code (whatever that would be) in the website’s footer to hook to a certain class to add a hover effect so that when people hover over a certain paragraph, a little text box with the disclaimer appears?

    Any suggestion?

    TabyP, you should just try the HTML Snippets plug-in.
    I’m really ticked I had to resort to it, but my PayPal buttons are now back where they belong.
    It allows you to insert shortcode in place of what you need.

    I actually linked it in this post, but like everything else WP-related, it doesn’t work.

    <a href="https://www.ads-software.com/plugins/insert-html-snippet//"></a>

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘Javascript in WordPress pages’ is closed to new replies.