Replacing links detected in a HTML with other links using JS

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2010-03-15T19:55:23Z Indexed on 2010/03/15 19:59 UTC
Read the original article Hit count: 308

Filed under:

Hi people.

I'm having a bit of trouble figuring out how to do this one.

Here's the scenario. My e-commerce site has a blog with a lot of content, promoting the products I sell, reviewing them etc. 99% of the posts on the blog link back to the products they are talking about.

I'm going to be changing the URL where my ecommerce system is located. Therefore my blog is going to end up sending people to a lot of 404 pages.

The idea I've had is to be able inclue a JS file which will on load, scan the document for existing links then, if found, swap them out with ones which are now correct.

I hope this make sense.

Cheers, Jim


© Stack Overflow or respective owner

Related posts about JavaScript