[英]Excluding a Site Anchor Link javascript
I do have this Code:我有这个代码:
<script>
var link = document.getElementsByTagName("a:not(#)");
for (var i = 0; i < link.length; i++) {
link[i].href = link[i].href.replace(/(\?)utm[^&]*(?:&utm[^&]*)*&(?=(?!utm[^\s&=]*=)[^\s&=]+=)|\?utm[^&]*(?:&utm[^&]*)*$|&utm[^&]*/gi, '$1');
}
</script>
The Code should lookup for all a
tags on the Site and replace all UTMs.该代码应查找所有
a
网站上的标签和替换所有的UTM。 Works so far.到目前为止工作。 But there are Anchor Tags on the site wich are now broken.
但是网站上的锚标签现在已损坏。
In the code of the site the Link looks like:在网站的代码中,链接看起来像:
<a href="#newspaper" class="someclass">Newspaper</a>
When I hover over the Link it shows me:当我将鼠标悬停在链接上时,它会显示我:
https://www.mysite.or/#newspaper
How do I exclude those Anchor Tags?如何排除这些锚标签?
此代码返回所有链接,不包括锚点
document.querySelectorAll('a:not([href*="#"])');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.