Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Looking for JS code to highlight a URL
Old 09-17-2008, 03:44 PM Looking for JS code to highlight a URL
Skilled Talker

Posts: 53
Name: Dave
Location: Kansas, USA
Trades: 0
I am looking for some JS code that will search for URLs in text and put the HREF tags around it to make it a link.

Anyone have such a monster?

Thanks!
dnavarrojr is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-17-2008, 05:13 PM Re: Looking for JS code to highlight a URL
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
well it's sort of possible but would suffer from the same problems as this does
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-17-2008, 06:46 PM Re: Looking for JS code to highlight a URL
Skilled Talker

Posts: 53
Name: Dave
Location: Kansas, USA
Trades: 0
Quote:
Originally Posted by chrishirst View Post
well it's sort of possible but would suffer from the same problems as this does
I am not looking for something perfect as this is not for a public web site.

I cracked open my JavaScript Bible and wrote the following which has flaws, but works for my needs:
Code:
function linkURL(strTxt)
{
  strTxt = strTxt.replace(/(([fh]+t+p\:\/+)+(\S+))/gi,"<a href=\"$1\" target=\"_new\">$1<\/a>");
  strTxt = strTxt.replace(/([a-z0-9\-\.]+\@[a-z0-9\-]+\.\S+)/gi,"<a href=\"mailto:$1\" target=\"_new\">$1<\/a>");
  return strTxt;
}
dnavarrojr is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Looking for JS code to highlight a URL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12956 seconds with 12 queries