how to replace a image url in all occurrences of it in html
i have a blogger blog. there is one image which i put in each of my blog's post( of my signature). earlier it was hosted on an im开发者_Go百科age hosting site but now i want it to put it on my own site since the old hosting site may delete it any time. how can i replace all occurrences of the image previous url with the new url without changing it manually in each post?
it is almost impossible to do it manually because i already have made more than a hundred posts.
like is there any code which i can insert in the template which will replace the previous url with the new one whenever a page is opened?
With jQuery: -
$("a").each(function() {
var existingURI = $(this).attr('href');
$(this).attr('href', './path_to_new_location/' + existingURI);
});
If you're not sure how to use jQuery comment here and i'll give you a hand. Js Fiddle here: http://jsfiddle.net/jTnpk/
Are you able to copy all of your blog's HTML contents, because if you were able to then you could simply paste them into any good text editing software like Notepad++ from there you could go to "Replace..." under search and after typing in the old link in one and the new link in the other hit "Replace All" and from there you could just copy all the code and paste it back, if you have that option, if not you could add a script to the page which goes a little something like this:
<script>
for(i=0;i<document.links.length;i++)
{
if(document.links[i].href == /*Insert old link here*/)
document.links[i].href = /*Insert new link here*/ ;
}
</script>
精彩评论