Useful JavaScript String Functions
page 1 of 3
Published: 10 Oct 2003
Abstract
HTML code for three string functions: making appropriate strings (e.g., http) clickable, removeHTML, and extract and list links in a string.
by Taewook Kang
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 49894/ 393

Clickify

Here are some of the string functions I have written. They can be used either client-side or server-side, although smartRmHTML would need the server.HTMLEncode method removed if it were used client-side. Enjoy!

function autoHTML( strSrc,optAtt ) {
 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 // autoHTML function
 // author: T. Kang
 // contact: txkang@hotmail.com
 // This function will make http,https,ftp,www and email strings clickable.
 //+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
 
 strSrc = strSrc.replace( /\s(https:\/\/|http:\/\/|ftp:\/\/|www.)([^\s]*)/gi,
   ' <a href=http://$2 ' + optAtt + '>$1$2</a>' );
 strSrc = strSrc.replace( /\s([^\s]*@[^\s]*)/gi,' <a href=mailto:$1>$1</a>' );
 return strSrc;
}

View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 6 and 6 and type the answer here:

User Comments

Title: simpler version of clickify (that works)   
Name: BC
Date: 7/3/2008 5:52:35 PM
Comment:
Hey commenters,

I found this other script which works like clickify. Clickify didn't work for me, but this one works out of the box:

http://www.codeproject.com/KB/scripting/replace_url_in_ajax_chat.aspx
Title: Does this work?   
Name: bitcloud
Date: 7/3/2008 5:48:23 PM
Comment:
I can't seem to get Clickify going at all... it just returns the same string... can you give an example usage?
Title: i want to see   
Name: francis
Date: 10/11/2007 7:52:11 AM
Comment:
how is i want to see the article
Title: How to use this?   
Name: SUNIL
Date: 8/24/2007 7:09:08 AM
Comment:
I ca'nt able to impliment, can u healp me?
Title: Very Helpful   
Name: David T.
Date: 5/17/2006 1:12:14 PM
Comment:
This is exactly what I was looking for! Saved me a ton of time. Thanks!
Title: w   
Name: w
Date: 4/5/2005 5:38:33 AM
Comment:
who create that function is seems to be brainish!

Product Spotlight
Product Spotlight 
Learn More
.NET Tools
asp.net shopping cart
asp.net chart control






Ads Powered by Lake Quincy Media
Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2008 ASPAlliance.com  |  Page Processed at 9/5/2008 5:46:34 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search