-
AuthorPosts
-
February 25, 2019 at 4:11 pm #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/#dictionaryFebruary 25, 2019 at 9:26 pm #1071472The 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 browsersMaybe 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 ruleFebruary 26, 2019 at 11:44 am #1071720Thank you Guenni007 it has work like a charm :)
February 26, 2019 at 1:57 pm #1071769This 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.February 27, 2019 at 9:35 pm #1072396 -
AuthorPosts
- The topic ‘if you click Masonry Gallery it should Open in New Tab’ is closed to new replies.
