I am using some JS code to find all internal links on a page and add a subfolder to them. This code is used on translated pages so internal links to other translated pages are correct.
I want to have this code update all internal links, unless they have a class attribute.
If the class attribute exists, I want the link to be ignored by the JavaScript function.
<a class="noTranslateLink" href="domain.com"
<script>
function replace_url(elem, attr) {
var elems = document.getElementsByTagName(elem);
for (var i = 0; i < elems.length; i++)
elems[i][attr] = elems[i][attr].replace('<?php echo $_SERVER['HTTP_HOST'] ?>', '<?php echo $_SERVER['HTTP_HOST'] ?>/ru');
}
window.onload = function() {
replace_url('a', 'href');
}
</script>