You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

autolink.js 489 B

123456789101112
  1. jQuery.fn.autolink = function() {
  2. return this.find('*').contents().filter(function () { return this.nodeType === 3; }).each(function() {
  3. var re = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-]*)?\??(?:[\-\+:=&;%@\.\w]*)#?(?:[\.\!\/\\\w]*))?)/g;
  4. $(this).each(function() {
  5. $(this).replaceWith(
  6. $("<span />").html(
  7. this.nodeValue.replace(re, "<a href='$1'>$1</a>")
  8. )
  9. );
  10. });
  11. });
  12. };