View Single Post
Old 12-12-2008, 02:58 PM   #3 (permalink)
buildakicker
The Acquainted
 
buildakicker's Avatar
 
Join Date: Jan 2008
Posts: 119
Thanks: 21
buildakicker is on a distinguished road
Big Grin

Quote:
Originally Posted by Wildhoney View Post
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!
__________________
SkiLeases.com
buildakicker is offline  
Reply With Quote