Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1071322

    Hi

    I like to open all content of masonary gallery in new tab.

    in order to do that ı have edit functions.php with following code of :

    https://kriesi.at/support/topic/masonry-gallery-custom-links-open-in-new-tab/

    In this case if you click the first 4 images which has preloaded it will open in new tab

    but if i click load more and add 4 more images and if i click new loaded images the page will open in the same browser so ı lose all load more images.

    How can i open masonary gallery always in new page

    You can visit my page to see this situation
    http://www.rawberrysnacks.com/#dictionary

    #1071472

    The thing is that these elements are created after the DOM has been loaded. So we had to have a “Listener” when there was a Change on the DOM.
    I knew that former function – and i know that this is a deprected one- but the function still seems to works in all browsers

    Maybe someone ( more competent than I am ) could tell us to do it with MutationObserver – This seems to be the modern variant of listening to DOM.

    function masonry_newtab(){
    ?>
    <script>
    (function($){
      $(document).ready(function($){ 
        $('body').on('DOMNodeInserted', function(){
          $('.av-masonry-container a').attr('target', '_blank');
        });
      });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'masonry_newtab');


    try this in functions.php of your child-theme instead the old rule

    #1071720

    Thank you Guenni007 it has work like a charm :)

    #1071769

    This function was simply ingenious, unfortunately this is a thing of the past and will probably no longer be supported properly in future browsers.
    The whole thing has probably been replaced by the MutationObserver method. I haven’t done it yet – at least not in a way that I know how to use it in combination with e.g. jQuery to insert the href attribute.
    Maybe one of the developers could give us some advice.

    #1072396

    Hi,

    Glad @Guenni007 could help!

    @Guenni007
    thanks as always :)

    Best regards,
    Yigit

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘if you click Masonry Gallery it should Open in New Tab’ is closed to new replies.