2009-08-24 78 views

回答

0

編輯:我不好,我完全誤讀/誤解了這個問題。爲了提供信息而留下原始答案。

不是我的頭頂。然而,它聽起來並不太難自己寫一個:

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 
} 

用法:

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

找到正則表達式的匹配網址和電子郵件地址的心不是很辛苦例如:urlemail

相關問題