Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1427405

    Hello everyone
    I found this support request from you here:

    I have inserted the part in the function.php.
    The script below I have inserted into the Customizer.css.
    Now I don’t understand where to put the
    <script type=”text/javascript”>
    have to insert?
    Can you help me with this?
    then I would like the popup to only appear on one page
    Page number: 11748
    Thank you very much
    kind regards
    Franz

    #1427406

    Hey schweg33,

    Thank you for the inquiry.

    You can add the script in a single page using the Code Block element from the Advance Layout Builder. Please check the screenshot below.

    Screenshot: https://savvyify.com/img/image/HOZQ

    Best regards,
    Ismael

    #1427408

    Many thanks
    Ismael
    could you insert this for me
    I don’t understand it

    Thank you
    kind regards Franz

    #1427431

    keep in mind that the

    jQuery(window).load(function(){
    

    is deprecated, you now have to use:

    jQuery(window).on('load', function(){
    
    #1427434

    Thank you
    I have now entered it like this:

    jQuery(window).on(‘load’, function(){
    ?>
    <script>
    (function($){
    $(document).ready(function () {
    setTimeout(function() {
    $(‘a.open-popup-link’).trigger(‘click’);
    },500);
    });
    })(jQuery);
    </script>
    <?php
    }
    add_action(‘wp_footer’, ‘custom_script’);

    #1427445

    hm ?

    some thoughts on custom scripts via functions.php

    you can do that:

    function custom_script(){
    ?>
    <script type="text/javascript">
    (function($) {
      $(window).on('load', function(){
        $('.open-popup-link').trigger('click');
      });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_script');

    Maybe – i think it will be enough to just wait til DOM is loaded and not the whole page
    so this could therefore be sufficient

    function custom_script(){
    ?>
    <script type="text/javascript">
    window.addEventListener("DOMContentLoaded", function () { 
    	(function($) {
    	    $('.open-popup-link').trigger('click');
    	})(jQuery);
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_script');

    But
    did you really got that class on the anchor?
    Lets say you got a button as trigger for the inline popup loading. And you gave a custom class to that button element – the class will be at the button wrapper – not the anchor!

    so the selctor must be different:

    function custom_script(){
    ?>
    <script type="text/javascript">
    window.addEventListener("DOMContentLoaded", function () { 
    	(function($) {
    	    $('.open-popup-link a').trigger('click');
    	})(jQuery);
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_script');
    #1427452

    many thanks together
    now everything fits
    you can close this request

    kind regards

    Francis

    #1427485

    Hi,
    Glad Guenni007 could help, thank you Guenni007, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘insert javascript’ is closed to new replies.