Javascript: find URLs in a document

Posted by user317005 on Stack Overflow See other posts from Stack Overflow or by user317005
Published on 2010-04-14T22:48:36Z Indexed on 2010/04/14 22:53 UTC
Read the original article Hit count: 261

Filed under:
|
|
|

how do I find URLs (i.e. www.domain.com) within a document, and put those within anchors: < a href="www.domain.com" >www.domain.com< /a >

html:

Hey dude, check out this link www.google.com and www.yahoo.com!

javascript:

(function(){var text = document.body.innerHTML;/*do replace regex => text*/})();

output:

Hey dude, check out this link <a href="www.google.com">www.google.com</a> and <a href="www.yahoo.com">www.yahoo.com</a>!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dom