How to hide the Google Invisible reCAPTCHA badge

前端 未结 15 2225
感情败类
感情败类 2020-12-02 04:15

When implementing the new Google Invisible reCATPTCHA, by default you get a little \"protected by reCAPTCHA\" badge in the bottom right of the screen that pops out when you

15条回答
  •  清歌不尽
    2020-12-02 04:52

    For users of Contact Form 7 on Wordpress this method is working for me: I hide the v3 Recaptcha on all pages except those with Contact 7 Forms.

    But this method should work on any site where you are using a unique class selector which can identify all pages with text input form elements.

    First, I added a target style rule in CSS which can collapse the tile:

    CSS

     div.grecaptcha-badge.hide{
        width:0 !important;
    }
    

    Then I added JQuery script in my header to trigger after the window loads so the 'grecaptcha-badge' class selector is available to JQuery, and can add the 'hide' class to apply the available CSS style.

    $(window).load(function () { 
        if(!($('.wpcf7').length)){ 
          $('.grecaptcha-badge').addClass( 'hide' );
           }
    });
    

    My tile still will flash on every page for a half a second, but it's the best workaround I've found so far that I hope will comply. Suggestions for improvement appreciated.

提交回复
热议问题