![]() | |||||
![]() |
|||||||||||||
|
Use Javascript to Link All Email Addresses in a Page
Posted by David Hammond, 2/14/2008
This came up with a site that needed to have a mailto link for email addresses, but other methods of linking the value didn't work. The same basic method could be used to replace any text in a page. <script type="text/javascript"> [\w\.\-]+\@([\w\-]+\.)+[\w]{2,4}The next part uses somewhat more advanced regular expression syntax:(?![^<]*>)The (?!... notation says that the email address will only match is it is not followed by [^<]*>, which should ensure that it is not within a property of an html tag. |
July 15, 2008 --
May 22, 2008 --
May 13, 2008 --
April 2008 --
April 2008 --
March 7, 2008 --
January 30, 2008 --
|
||||||||||||