Javascript that changes specific href link to new one? (no jquery) -


friends, can give me simple javascript change href link new 1 on posts in blogger blog.

<a href="http://domainone.com/brb.php"> 

to become

<a href="http://domaintwo.com/brb.php"> 

the problem domainone no longer available , need mass change when user asks domain directed new one.

please no jquery oldschool javascript.

regards!

you can use .setattribute(), this:

var links = document.getelementsbytagname('a')  for(var i=0;i<links.length;i++){     if(links[i].getattribute('href') && links[i].getattribute('href').indexof('domainone') >=0 )      links[i].setattribute('href', 'http://domaintwo.com/brb.php');  }
<a href="http://domainone.com/brb.php">link</a>


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -