var sayt = location.href alert(sayt);
alert(location.protocol+"//"+location.hostname);
<a href="http://google.com">Search</a> <script> function replace_outlinks(replacement) { links=document.getElementsByTagName("a"); for (var i=0; i!=links.length; ++i) { if(links[i].href.search("http") != -1) links[i].href= replacement; } }; replace_outlinks("http://yandex.ru"); </script>