Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Force all external links into a new tab?


joeljanski
Go to solution Solved by llmodbls,

Question

I am trying to get the clickthrough URL of each image in my galleries to open in a new tab. I did some digging and I noticed that each gallery image has the <div class="margin-wrapper"> on it. So I am thinking if I can have anything that has that class open in a new tab I should be good?

How can I change all external links contained within <div class="margin-wrapper"> to automatically open in a new blank target tab?

Edited by acalvo
retag
Link to post
  • Answers 21
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

To make them universal just place this code in header injection on all pages you wish all links to be forced to open in a new tab: <base target="_blank"/> Works really well.

This only works if you are coding the link yourself. You can't put that stuff in the Clickthrough URL for an image . . . when I try it tells me to please enter a valid URL.

Can you share link to an example page?

21 answers to this question

Recommended Posts

  • 0

Usually I just make the link say:


<a href="http://www.whatever.com" target="_blank">link text</a>

So, pretty much just adding target="_blank" inside your link code will make clicking the link open a new tab (or window; depending on the visitor’s browser preferences).

Not sure how to code it to be universal, or if you can. I’ve only ever done it on individual link codes.

Edited by llmodbls
Format
Link to post
  • 1

I made and account on this site JUST to answer this. That's how much thankful I am.I've been struggling with this for like 2 hours, damn it! Your answer just solved it automagically.

I have a page with dynamic content generated through a php function and trying to assign the target blank attribute to links within a div class didn't work. Your solution just did.

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!

Link to post
  • 1

I came across this similar issue when displaying blog posts in a summary block. If the "Link Post Title to Source URL" option is selected, there is no way to make the link open in a new tab.

I found a solution in another post on this form that is counter intuitive but seems to work. Adding "target="_blank to the end of the Source URL will add the target="_blank" to the html. For example: https://link-to-outside-source.com"target="_blank  Yes, I know, the code looks wrong if you are use to writing html, but try it. Plus, no JS is required for those on the lower level subscriptions. 

Link to post
  • 0

Hi all, I tried adding target="_blank" to the end of my redirect url but it isn't working. I've waited approximately 30mins and it still isn't working. Any suggestions?

This is what it currently looks like: https://embodhii.org/emotional-freedom2pxiu8yh"target="_blank

Thanks in advance!

Link to post
  • 0

@clro it should be

<a href="https://embodhii.org/emotional-freedom2pxiu8yh" target="_blank">Text link</a>

or

<a href="https://embodhii.org/emotional-freedom2pxiu8yh" target="_blank">https://embodhii.org/emotional-freedom2pxiu8yh</a>

 

You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan, work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. 

Link to post
  • 0
On 6/28/2019 at 3:35 AM, Byler_Media said:

Just tried this and it worked to only apply to a certain block:



 

<base #yourBlockId target="_blank"/>


Any idea how to add this to an external email link? thanks so much

 

 

Link to post
  • 0
9 hours ago, zoebrock said:

 

Can you share link to an example page?

You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan, work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. 

Link to post
  • 0
4 hours ago, tuanphan said:

Can you share link to an example page?

Hi yes it's the same one I  emailed you about 🙂 The Enquire link in the lightbox pop ups for all the images on Johngollings.com

Link to post
  • 0

try adding to Code Injection Footer

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('[href*="mail"]').attr('target','_blank');
});
</script>

 

You can send your question to my email to get faster answer. / How to Setup Password & Share URL 

-- I'm Tuan, work for a non-profit project (build free libraries). I check the forum once or twice a day to help out the community. If you don't see me answering your question, you can send it to the email above. 

Link to post
  • 0

This is really easy to do, but Squarespace makes you go through several steps.

All you need to do is go to the page with the link you want to edit. Choose Edit Page and then highlight the link. This should bring up the link editor (if not you can click the link button on the toolbar.)

Now this is where it gets tricky. You have to go to edit, THEN you have to click the gear icon, THEN you need to switch the toggle switch to open link in new window. THEN you have to click save at the top of the link editor window. THEN you have to click "apply' at the bottom of the little link editor box. THEN you have to click on "save" at the top of the page editor to save your page.

Edited by aladdinsane
word
Link to post
  • 0

It worked!

On 7/15/2020 at 7:13 AM, Tarjo said:

I came across this similar issue when displaying blog posts in a summary block. If the "Link Post Title to Source URL" option is selected, there is no way to make the link open in a new tab.

I found a solution in another post on this form that is counter intuitive but seems to work. Adding "target="_blank to the end of the Source URL will add the target="_blank" to the html. For example: https://link-to-outside-source.com"target="_blank  Yes, I know, the code looks wrong if you are use to writing html, but try it. Plus, no JS is required for those on the lower level subscriptions. 

You are the only person in this whole thread who actually responded adequately to the problem of using the "Clickthrough URL" field in gallery image settings, and your solution totally works, as weird as it is! Thanks so much for solving a problem I've had for a long time! Helpful to know it works for the "Link Post Title to Source URL" feature too.

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...