How can I use javascript to convert relative href attributes into absolute paths?
Posted
by jhensley2
on Stack Overflow
See other posts from Stack Overflow
or by jhensley2
Published on 2009-05-06T19:51:33Z
Indexed on
2010/03/13
8:15 UTC
Read the original article
Hit count: 215
I have a template that gets screenscraped from an outside vendor and need to include absolute paths in the navigation so the externally hosted content will properly link back to our site.
Right now the page/template is driven by a global menu app written by our back end development staff... so anyone who updates our site goes in and changes the menus and their paths...
Right now all of the links are linking to relative paths back to the root.
For example
<a href="/">Home</a>
<a href="/news/">News</a>
<a href="/media/">Media</a>
<a href="/other/">Other</a>
I need a simple way (preferably with jquery) to prepend "http://www.domain.com" to each of those links.
© Stack Overflow or respective owner