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

How to get links to open a new tab ONLY on one page


chard
Go to solution Solved by creedon,

Question

  • Answers 11
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

Oh, I see. Yes, it looks like my Firefox's adblock did block the new tab. It works just fine on safari on my phone. Thank you for your help! 🙂

Posted Images

11 answers to this question

Recommended Posts

  • 1

Add the following to Settings > Advanced > Code Injection > HEADER.

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Add the following to Page Settings > Advanced > PAGE HEADER CODE INJECTION for the page.

<script>

  $( ( ) => {
  
    $( '.blog-more-link' ).attr ( 'target', '_blank' );
    
    } );
    
  </script>

Let us know how it goes.

Edited by creedon
version 2 of second script

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to post
  • 0

When you are testing the base tag are you in edit mode? If so then the edit mode overrides the base tag behaviour in my testing.

Keep your base tag in the Page Header Code Injection for the page you want the links to open to a new page.

Then the trick is to get out of edit mode to test the behavior is correct.

Hit the arrow or the escape key (if you have that enabled).

1203937310_ScreenShot2020-09-26at11_06_39PM.png.ba73383c3653873cbeb6b7baa915c30f.png

Once out of edit mode you should see the following URL.

560640756_ScreenShot2020-09-26at11_08_05PM.png.4159cc6cb3a684377817f8a263f66128.png

To that URL add ?noredirect and hit return to go to that URL.

358966355_ScreenShot2020-09-26at11_10_26PM.png.a7b1f55af5a3995556121ea0ae1289a5.png

This should help you not fallback into edit mode by accident.

Now click on a link on that page. Does it open a new window or tab?

To get back into edit mode hit escape key (if enabled). Or add "config/" (without the quotes) to the base URL of your website.

Let us know how it goes.

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to post
  • 0

It's not an issue of whether or not the code is allowing for the tabs to open up in a new tab. It's that with the code, every single link throughout the whole domain opens up into a new tab when we've tested it outside of edit mode. We'd like to know how we can get it only for the particular story page, rather than throughout the whole website. Any idea might be up with it?

Link to post
  • 0

I am unable to reproduce the behaviour you describe. I put that base tag in Page Settings > Advanced > Page Header Code Injection for a test page on my test site. Only that page opens links into a new window/tab. Links on other pages are unaffected.

459629545_ScreenShot2020-09-30at11_43_42PM.png.61f8513e3c7ee040e283e371e0b2cb42.png

1622863039_ScreenShot2020-09-30at11_44_21PM.png.e1f7d5b3310c57287431ff34dcabc0e2.png

Edited by creedon
added pics for clarification

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

Link to post
  • 0

Hmm. After a bit of experimenting, it seems that the code makes all of the links in the site header open up in a new tab. I would like to be able for it to only happen for the "Read more" links I have under the blog stories. With that code, and a site header, you should see the behavior replicate itself in the site header.

Link to post
  • 0

I've put both scripts in their respective locations and it doesn't seem to do anything. Clicking on the links will only bring me to the page, but not create a new tab.

Link to post
  • 0

When I click on read more links on that page a new tab is opened in my browser. I can see that the code you added is working.

The following pics show the code is there and working.

599176596_ScreenShot2020-10-15at12_28_08PM.png.22287e484f5b8c95c4e8cc25ad8a390e.png

 

1252510638_ScreenShot2020-10-15at12_27_23PM.png.599242ec446d88a03fb60ba8506c2efb.png

My thinking is that your browser is blocking the target _blank behaviour. Perhaps a security setting to prevent pop ups. It could also be ad blocker software.

Find my contributions useful? Please like, upvote, mark my answer as best , and see my profile. Thanks for your support!

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