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

Force all external links into a new tab?

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

Share this post


Link to post

14 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

Share this post


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!!!!!!!!!!!!!!!!!!!!!!!

Share this post


Link to post
  • 0

This worked great, except that it opens header links in a new window too. Anyone know how to get around that? Thanks!

Share this post


Link to post
  • 0

This worked great, except that it opens header links in a new window too. Anyone know how to get around that? Thanks!

Share this post


Link to post
  • 0
Posted (edited)

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


<base #yourBlockId target="_blank"/>


Edited by BylerMedia
Initial Revision

Share this post


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!

Share this post


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>

 

Share this post


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...