SpaceRants Posted April 6, 2021 Share Posted April 6, 2021 Site URL: https://www.spacerants.com/ On the "Listen" section of my home page are twelve buttons (really hyperlinked images) to various podcasting platforms. Spotify, Stitcher, etc. For these "buttons" to wrap and scale properly, I must use a "summary" block set to "Grid." Problem is, clicking on the images now opens the link in your current tab, rather than creating a new one. To solve this I found and deployed this code in the footer: <script> document.querySelector('.sqs-block-summary-v2 a').setAttribute('target', '_blank'); </script> So far I've succeeded in making the first image in the summary block open its link in a new tab, but every other image still opens the link in the current tab. I'm guessing a minor change to the existing code will solve this, but I'm in over my head at this point. Help! Beyondspace 1 Link to comment
Solution Beyondspace Posted April 9, 2021 Solution Share Posted April 9, 2021 On 4/7/2021 at 1:43 AM, SpaceRants said: Site URL: https://www.spacerants.com/ On the "Listen" section of my home page are twelve buttons (really hyperlinked images) to various podcasting platforms. Spotify, Stitcher, etc. For these "buttons" to wrap and scale properly, I must use a "summary" block set to "Grid." Problem is, clicking on the images now opens the link in your current tab, rather than creating a new one. To solve this I found and deployed this code in the footer: <script> document.querySelector('.sqs-block-summary-v2 a').setAttribute('target', '_blank'); </script> So far I've succeeded in making the first image in the summary block open its link in a new tab, but every other image still opens the link in the current tab. I'm guessing a minor change to the existing code will solve this, but I'm in over my head at this point. Help! You gotta select ALL items, modified code as follow <script> document.addEventListener('DOMContentLoaded', function() { var summary = document.querySelectorAll('.sqs-block-summary-v2 a'); summary.forEach(function(item) { item.setAttribute('target', '_blank'); }); }); </script> Element.querySelectorAll() - Web APIs | MDN (mozilla.org) tuanphan 1 BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations) 🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
SpaceRants Posted April 9, 2021 Author Share Posted April 9, 2021 Thank you so much bangank36! Works perfectly. Beyondspace 1 Link to comment
bluShiftAero Posted June 7, 2021 Share Posted June 7, 2021 On a website with multiple galleries, how would you update the selector for just one gallery? Link to comment
tuanphan Posted June 8, 2021 Share Posted June 8, 2021 On 6/7/2021 at 9:53 PM, bluShiftAero said: On a website with multiple galleries, how would you update the selector for just one gallery? replace this class name Quote .sqs-block-summary-v2 a with Quote #summary-block-id a Find summary block id with this tool https://chrome.google.com/webstore/detail/squarespace-id-finder/igjamfnifnkmecjidfbdipieoaeghcff?hl=en Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment