When I upgraded my webiste from M2.3.5 to M2.4.2, I get this notice "The store will not work correctly in the case when cookies are disabled." on top of head frontend for 3 seconds. But I installed a new M2.4.2 have not get that notice(Cookie Restriction Mode = No) . I found div id named "cookie status" The store will not work correctly in the case when cookies are disabled. but I can't find which file can control this. I don't need the notice display, so how to do that? Thanks

enter image description here

enter image description here

enter image description here

有帮助吗?

解决方案

It's taking time to hide because there is using js for hide. you can use css for hide instaed of $script = 'document.querySelector("#cookie-status").style.display = "none";';

Content comes from vendor/magento/module-theme/view/frontend/templates/js/cookie_status.phtml

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>

<div id="cookie-status">
    <?= $block->escapeHtml(__('The store will not work correctly in the case when cookies are disabled.')); ?>
</div>
<?php
$script = 'document.querySelector("#cookie-status").style.display = "none";';
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', ['type' => 'text/javascript'], $script, false); ?>

<script type="text/x-magento-init">
    {
        "*": {
            "cookieStatus": {}
        }
    }
</script>
许可以下: CC-BY-SA归因
scroll top