Sunday, July 26, 2009

[jQuery] Using jQuery to automatically convert plain-text URLs to links

On my site, I would like to have jQuery automatically convert all
plain-text URLs to links.

For example, if I have the following in the BODY tag of my Web page:

Go to http://groups.google.com to go to the Google Groups home page.

I want it to be converted in to this:

Go to <a href="http://groups.google.com">http://groups.google.com</a>
to go to the Google Groups home page.

I'm sure the prepend() and append() functions will be used, but how do
I tell jQuery how to pick URLs out of the Web page, if they are not
surrounded by separate tags? I'm sure if each URL was in a SPAN tag it
would be much easier.

Any ideas?

Thanks,
stickynote427

No comments: