Add domain to relative urls
How can I add http://facebook.com to relative URL's contained within #facebook_urls? Eg:
<a href="/test.html">
becomes
<a href="http://facebook.com/test.html">
#facebook_urls also co开发者_JAVA技巧ntains absolute urls, so I want to make sure I don't touch those.
Something like this?
$('#facebook_urls a').each(function() {
if(!this.href.match('^http')) {
this.href = "http://facebook.com/" + this.href
}
})
加载中,请稍侯......
精彩评论