var webRoot = "http:****:8000/seeyon" var allHref = document.getElementById('htmlContentDiv').getElementsByTagName('a'); for (var i = 0; i < allHref.length; i++) { if(!allHref[i].href.startsWith('javascript'))allHref[i].setAttribute('target','_blank'); }