2009-08-24 7 views

Antwort

0

EDIT: Mein schlechtes, ich missverstanden völlig/missverstanden die Frage. Linke ursprüngliche Antwort für informative Zwecke.

Nicht von ganz oben in meinem Kopf. Allerdings ist es nicht zu hart klingt selbst eine Beurteilung zu schreiben:

function UrlToLink(url) { 
    // 1. check if url IS a url or email using a regex 
    // 2. if it isnt return null/false 
    // 3. create a DOM `<a></a>` element and populate the href attribute with url (mailto:url if email) and the inner text 
    // 4. return element 
} 

Verbrauch:

document.appendChild(UrlToLink("http://a.url.com/")); 

regex der Suche nach URLs und E-Mail-Adressen sind nicht sehr schwer ex passen: url, email

Verwandte Themen