5

Due to problems with autoscrolling, I had to replace my blog theme on Tumblr. On this new theme all external links open on a new tab, even after deleting all the target="_blank"> on the code.

When I try the code on the blog itself it puts the target="_blank"> back in the code.

If for example I leave a link like this:

<a href="EXTERNAL-WEB-SITE-GOES-HERE">
                    <svg class="social-accounts-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 242.8 242.8" enable-background="new 0 0 242.8 242.8" xml:space="preserve">
    <path fill="#AAAAAA" d="SVG-VECTOR-CODE-GOES-HERE"/>
</svg>
 </a>

When inspecting the code on the blog using F12 on Chrome ends up like this:

<a href="EXTERNAL-WEB-SITE-GOES-HERE" target="_blank">
                    <svg class="social-accounts-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 242.8 242.8" enable-background="new 0 0 242.8 242.8" xml:space="preserve">
    <path fill="#AAAAAA" d="SVG-VECTOR-CODE-GOES-HERE"></path>
</svg>
 </a>

I already tested the blog using both Chrome and Firefox and I get the same result.

You can check the blog code on this pastebin: https://pastebin.com/LpkPMugw

Thanks for reading.

sao
  • 1,835
  • 6
  • 21
  • 40

1 Answers1

3

You could use jQuery for that:

<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function($){
    $('.site-content a').each(function(){
        if( $(this).attr('href') && 0 != $(this).attr('href').indexOf('#') ) {
            $(this).attr('target', '_self');
        }
    });
});
// ]]></script>

If you add that code to your site it will change all links inside of the .site-content container to have a target=_self

MistaPrime
  • 1,591
  • 1
  • 10
  • 20
  • put the code on the blog before , before and then before ; but unfortunately it didn't resolved the problem, it still reverts to "target=_blank" when the site loads for some reason. – kratosbrawl Oct 15 '19 at 22:34
  • 2
    Try putting it at the end such as in the footer. And ensure that you have jQuery load on the site as well. – MistaPrime Oct 16 '19 at 01:00
  • revised the code and though it did had a jquery on it, it wasn't completely working, so i added another jquery code from their website and added the previously mentioned code that forces the pages to go ```target=_self``` like this: ``` ``` And the blog now work as intended, thanks a lot for the help! – kratosbrawl Oct 16 '19 at 01:55