Replace URL with HTML Link with Javascript and Jquery Plugins
Wall Script
Thursday, May 27, 2010

Replace URL with HTML Link with Javascript and Jquery Plugins

This post contains useful jquery plugins and javascript tip how to replace text URL to HTML links. I had tried these plug-ins at labs.9lessons. I hope it's very useful for your social media web projects. Thanks!


Javascript Text to Link
<script type="text/javascript">
function text_to_link(text)
{
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1' target='_blank'>$1</a>");
}
var linkdata=text_to_link("9lessons programming blog http://www.9lessons.info");
document.write(linkdata);
</script>

Useful Jquery Plugins
Was this article helpful?
Thanks! Your feedback helps us to improve 9lessons.info


7 comments:

  1. you can even make it a userscript for all websites

    ReplyDelete
  2. that's all cool & great js , thank you very much for sharing.

    ReplyDelete
  3. Don't get your point

    ReplyDelete

Make in India