12-12-2008, 02:58 PM
|
#3 (permalink)
|
|
The Acquainted
Join Date: Jan 2008
Posts: 119
Thanks: 21
|
Quote:
Originally Posted by Wildhoney
Try the following code:
javascript Code:
function TalkPHP_MakeLinks(pWithinElement) { if (!pWithinElement) { return false; } var szContent = pWithinElement.innerHTML; pWithinElement.innerHTML = szContent.replace(/(http:\/\/.+?)[\s|\n]/ig, '<a href="$1">$1</a> '); }
|
Thanks for the response, works perfect. I am not sure I understand how it is working however. Are these comments correct:
function TalkPHP_MakeLinks(pWithinElement)
{
//if there is no DIV with this name, do nothing.
if (!pWithinElement)
{
return false;
}
//this var equals the DIV to be "edited"
var szContent = pWithinElement.innerHTML;
//this finds the HTTP and makes it a link...
pWithinElement.innerHTML = szContent.replace(/(http:\/\/.+?)[\s|\n]/ig, '<a href="$1">$1</a> ');
}
Can you explain this:
http:\/\/.+?)[\s|\n]/ig
Thanks again! 
|
|
|
|