1
Oops, I have a script that identifies all external links and force open in new tab...
<script>
jQuery(document).ready(function($){
$('a').not('[href*="'+document.domain+'"]').attr('target', '_blank');
$('a').not('[href*="'+document.domain+'"]').attr('rel', 'external nofollow');
});
</script>
But how to make it not force a domain..., that is.. all domains open in a new tab.. except that of "algumsite.com"?? that is.. only links from this domain will not open in new tab.
I tried to do so:
<script>
jQuery(document).ready(function($){
$('a').not('[href*="'+document.domain+'"]').attr('target', '_blank');
$('a').not('[href*="'+document.domain+'"]').attr('rel', 'external nofollow');
$('[href*="ads.onlinee.top"]').removeAttr("target");
});
</script>
But the ad links.. (EXTERNAL LINKS OPEN AGAIN IN THE SAME TAB)
I believe with regex you can do this
– Alvaro Alves
I think if I add one more
.not
Voce achieves the result.$('a').not('[href*="'+document.domain+'"]').not('[href*="algumsite.com"]').attr('target', '_blank');
– Icaro Martins
this someone.com has to open on the same page!
– Matheus Vitor
I tried that one, it didn’t work!
– Matheus Vitor
All of the same domain or ["some.com", "othotambem.com"] must open on the same page?
– Leandro Angelo
All of the domain "site01.com" opens in the same tab... other external domains.. open in new tab..
– Matheus Vitor
In the code I put up he was putting target for the elements to whose href didn’t have the current domain and someone with.. It may be that your link already has the
target='_blank'
, then Voce needs to remove thetarget
. You can select it and remove with the following code$('[href*="algumsite.com"]').removeAttr("target")
. jQuery Selectors– Icaro Martins
I put another one... but it stopped working the others..
– Matheus Vitor
I put in question my attempt... added your code..
– Matheus Vitor
Also add html, as declared
<a href="">
– Leandro Angelo
what do you mean ? how do I put it ?
– Matheus Vitor