• Resolved Newki75

    (@newki75)


    Hello guys,

    On my site, I had to display a page in an iframe in another page. So a new visitor sees the banner twice : at the bottom of the real page and in the iframe. How can I hide it in the iframe. Txxxxxx for your help,
    Nice day

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @newki75,

    To hide the banner in the iframe, please add below code snippet to your site’s active child theme’s functions.php

    add_action('wp_footer', 'hide_iframe_cookiebar');
    function hide_iframe_cookiebar() {
    	?>
    	<script>
    		jQuery(function(){
    			jQuery('#iframeID').on('load', function() {
    				jQuery('#iframeID').contents().find('#cookie-law-info-bar').hide();
    				jQuery('#iframeID').contents().find('#cookie-law-info-again').hide();
    			});
    		});	
    	</script>
    	<?php
    }

    Please make sure to replace iframeID with the iframe’s ID.

    Thread Starter Newki75

    (@newki75)

    Tx for your answer !
    To replace iframeID by iframe’s ID, can you confirm you speak about ID of the div including the iframe?

    And I’m not a php specialist at all but at the moment, my functions.php file finished with the last command and not
    <?php
    }

    Isn’t there a mistake here? Because I’ve copied this code with my Div ID
    add_action(‘wp_footer’, ‘hide_iframe_cookiebar’);
    function hide_iframe_cookiebar() {
    ?>
    <script>
    jQuery(function(){
    jQuery(‘#iframe-mirialis’).on(‘load’, function() {
    jQuery(‘#iframe-mirialis’).contents().find(‘#cookie-law-info-bar’).hide();
    jQuery(‘#iframe-mirialis’).contents().find(‘#cookie-law-info-again’).hide();
    });
    });
    </script>
    <?php
    }

    And the bar is still there.
    Txxxx for your help WebToffee

    Plugin Author WebToffee

    (@webtoffee)

    Hi @newki75,

    It is not the div ID. You must include the iframe ID.

    Please share the site URL if you need any help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide cookie consent on a page set up in a iframe’ is closed to new replies.