johnhalldesign Posted April 21, 2020 Posted April 21, 2020 Building out a new site in 7.1, and I'm using a summary block to link some images to offsite pages. There are other ways I could do this, but the summary block gives me the best look and functionality for this. Only problem is, I don't have the ability to open the links in a new window, which I generally do with offsite links. Most other areas in Squarespace give you a toggle to chose to "open link in a new window", but I don't see this option in the summary block. There is a selection "Post Title should link to Source URL" but no option to open the link in a new window. Am I missing something, or is there any easy way to add this with code somehow, or any plans to add this feature?
tuanphan Posted April 22, 2020 Posted April 22, 2020 If you want to use code, you can use JS to add attribute: target="_blank" to link. Can you share link to summary block? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
johnhalldesign Posted April 30, 2020 Author Posted April 30, 2020 Site is here https://jameslang.squarespace.com (pass=langview) Its the section on the home page under "Recent Essays" The three illustrations and headlines all link to another site. Links are set in the Blog interface for each post by checking "Post Title Should Link to Source URL". Unlike other places, there is no choice to open that link in new window. I know how to use target="_blank" if I'm writing it out in a code box, but this is just a toggle, and I don't think I can just add that on to the URL can I? I'm only a hack coder, so maybe there is a way, but can't. understand why Squarespace does give you the new window option here, as they do most other places.
tuanphan Posted May 2, 2020 Posted May 2, 2020 On 4/30/2020 at 8:26 PM, johnhalldesign said: Site is here https://jameslang.squarespace.com (pass=langview) Its the section on the home page under "Recent Essays" The three illustrations and headlines all link to another site. Links are set in the Blog interface for each post by checking "Post Title Should Link to Source URL". Unlike other places, there is no choice to open that link in new window. I know how to use target="_blank" if I'm writing it out in a code box, but this is just a toggle, and I don't think I can just add that on to the URL can I? I'm only a hack coder, so maybe there is a way, but can't. understand why Squarespace does give you the new window option here, as they do most other places. Add to Home > Settings > Advanced > Code Injection > Footer <script> document.querySelector('.sqs-block-summary-v2 .summary-thumbnail-container').setAttribute('target', '_blank'); </script> jessone and artpimpress 1 1 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
johnhalldesign Posted May 5, 2020 Author Posted May 5, 2020 So that works on the first image thumbnail, but not the others or the headline links. Getting close though. Is there some adjustment that will hit the others?
tuanphan Posted May 5, 2020 Posted May 5, 2020 11 minutes ago, johnhalldesign said: So that works on the first image thumbnail, but not the others or the headline links. Getting close though. Is there some adjustment that will hit the others? Edit above code to <script> document.querySelector('.sqs-block-summary-v2 a').setAttribute('target', '_blank'); </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
johnhalldesign Posted May 5, 2020 Author Posted May 5, 2020 I actually went. back to your original selection and added "target="_blank right after the URL, and that did work. I didn't think it would unless I was writing out the full code, but seems it did. Thanks. tuanphan 1
SpaceRants Posted April 6, 2021 Posted April 6, 2021 Sorry - I'm a little confused. How did you modify the code? Currently I have: <script> document.querySelector('.sqs-block-summary-v2 a').setAttribute('target', '_blank'); </script> and only the first item in the gallery opens in a new tab.
tuanphan Posted April 12, 2021 Posted April 12, 2021 On 4/6/2021 at 11:09 PM, SpaceRants said: Sorry - I'm a little confused. How did you modify the code? Currently I have: <script> document.querySelector('.sqs-block-summary-v2 a').setAttribute('target', '_blank'); </script> and only the first item in the gallery opens in a new tab. try this <script> document.querySelector('.summary-item a').setAttribute('target', '_blank'); </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Estela Posted April 30, 2021 Posted April 30, 2021 https://www.seaforestation.com/seaweed-in-the-news Hi I am also looking for a custom code to allow me to open the links of the different summary blocks of this website in a new tab. Thank you! EarvinChong 1
tuanphan Posted May 1, 2021 Posted May 1, 2021 13 hours ago, Estela said: https://www.seaforestation.com/seaweed-in-the-news Hi I am also looking for a custom code to allow me to open the links of the different summary blocks of this website in a new tab. Thank you! Have you tried above code yet? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Estela Posted May 1, 2021 Posted May 1, 2021 Yes I did, but it doesnt work, I pasted the code on the page settings. Did I miss something?
Estela Posted May 2, 2021 Posted May 2, 2021 So I added /"target="_blank after the url link and it does open a new page but not in the right way. I attached the page is opening now. For some reason this code added the / to the url what is making an 404 error. The url would be correct without the /
Estela Posted May 2, 2021 Posted May 2, 2021 I fixed it! url and added "target="_blank it works perfect!!!!💃 EarvinChong 1
Estela Posted May 2, 2021 Posted May 2, 2021 so it does not work with youtube or video links. Any idea how to make it work? raeroshow 1
Estela Posted May 2, 2021 Posted May 2, 2021 So I found another solution to the youtube links if I use https://cutt.ly/ to shorten the url and then added "target="_blank it works 🙂
JennySquare Posted November 12, 2021 Posted November 12, 2021 Hi @tuanphan! I'm looking for a similar solution and can't find the right selector. I tried .blog-item a but that's not quite it. https://www.inqyr.org/research-hub Any suggestions? Thank you so much in advance.
Guest Posted November 13, 2021 Posted November 13, 2021 (edited) On 4/21/2020 at 10:31 PM, johnhalldesign said: Building out a new site in 7.1, and I'm using a summary block to link some images to offsite pages. There are other ways I could do this, but the summary block gives me the best look and functionality for this. Only problem is, I don't have the ability to open the links in a new window, which I generally do with offsite links. Most other areas in Squarespace give you a toggle to chose to "open link in a new window", but I don't see this option in the summary block. There is a selection "Post Title jackets should link to Source URL" but no option to open the link in a new window. Am I missing something, or is there any easy way to add this with code somehow, or any plans to add this feature? Do you try to add /"target="_blank attributes as it works fine in HTML section and helps you to open it in new tab. Edited November 13, 2021 by martybirdese
tuanphan Posted November 15, 2021 Posted November 15, 2021 On 11/13/2021 at 6:38 AM, JennySquare said: Hi @tuanphan! I'm looking for a similar solution and can't find the right selector. I tried .blog-item a but that's not quite it. https://www.inqyr.org/research-hub Any suggestions? Thank you so much in advance. Try this code <script> document.querySelector('h1.blog-title a').setAttribute('target', '_blank'); </script> JennySquare and EarvinChong 2 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
JennySquare Posted November 17, 2021 Posted November 17, 2021 Thanks for your reply! @tuanphan The code didn't work unfortunately. I gave this another search and found tried this method using jQuery. I altered the code and used the following: <script> $(document).ready(function() { $('.blog-item a').click(function(event) { event.preventDefault(); // preventDefault first var link = $(this).attr('href'); if(link != '#'){ window.open(link); } }); }); </script> Just for other folks using Universal Filter like I am for this example. StudioEightySeven, EarvinChong and tuanphan 3
valeayala Posted January 13, 2023 Posted January 13, 2023 Is there a way to apply this code universally across a site so that all summary block posts open in a new tab?
tuanphan Posted January 15, 2023 Posted January 15, 2023 On 1/14/2023 at 2:51 AM, valeayala said: Is there a way to apply this code universally across a site so that all summary block posts open in a new tab? Add to Code Injection > Footer <script> document.querySelector('.sqs-block-summary-v2 a').setAttribute('target', '_blank'); </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
nmbenson1 Posted March 29, 2023 Posted March 29, 2023 Hi @tuanphan I am trying to accomplish this universally with summary block click through URLs in the Brine template for 7.0. I've followed the above suggestions without success, do you know if this code is particular to 7.1? website: mwlit.com password: (press spacebar) pages: books < adults titles < childrens titles
tuanphan Posted March 31, 2023 Posted March 31, 2023 On 3/29/2023 at 10:23 AM, nmbenson1 said: Hi @tuanphan I am trying to accomplish this universally with summary block click through URLs in the Brine template for 7.0. I've followed the above suggestions without success, do you know if this code is particular to 7.1? website: mwlit.com password: (press spacebar) pages: books < adults titles < childrens titles Add to Settings > Advanced > Code Injection > Footer <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script> $(document).ready(function() { $('.summary-v2-block a').attr('target','_blank'); }); </script> nmbenson1 and rotanzdesign 2 Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment