Tagged: , , ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #367435

    Hi!

    I want to use the Fullwidth button to let users close a window. I know how to do it with a normal button using this code `<button type=”button”
    onclick=”window.open(”, ‘_self’, ”); window.close();”>Discard</button>`.

    [r.mlvr.nl/verzoek]

    Is this even possible?
    Any help would be appreciated!

    Many, many thanks,
    – Michael

    #367563

    Hi Michael,

    Set a custom class to the fwd button and add this at the very end of your theme / child theme functions.php file:

    function add_custom_script(){
    ?>
    <script>
    (function($){
        $(window).load(function() {
        	$('.custom-fwd-btn .avia-button').on('click', function(){
                     window.open(”, ‘_self’, ”); window.close();
            });
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    Regards,
    Josue

    #367674

    Hi,

    I can’t really figure this out.

    I’ve added the code to the end of my functions.php (child theme).

    But what should I enter as custom class?
    And what should I do with the button link?

    Fullwidth Button Settings

    Many thanks!
    Regards,
    Michael

    #367677

    hi,

    see this line of the code:
    $('.custom-fwd-btn .avia-button').on('click', function(){

    The class is “custom-fwd-btn”

    cheers

    • This reply was modified 9 years, 11 months ago by Flikk.
    #367796

    Hey!

    Yes, the custom class should be that (custom-fwd-btn), regarding the link try putting a #.

    Regards,
    Josue

    #837159

    This one worked for me:

    // Add close window functionality
    function add_custom_script(){
    ?>
    <script>
    (function($){
    $(window).load(function() {
    $(‘.close-window .avia-button’).on(‘click’, function(){
    window.open(”, ‘_self’, ”);
    window.close();
    });
    });
    })(jQuery);
    </script>
    <?php
    }
    add_action(‘wp_footer’, ‘add_custom_script’);

    #837850

    Hi afarahani,

    Thank you for sharing! :)

    Best regards,
    Victoria

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.