Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>According to: <a href="http://www.w3schools.com/jsref/jsref_link.asp" rel="nofollow">http://www.w3schools.com/jsref/jsref_link.asp</a> The String.link() method returns a text "blah" as a HTML link</p> <pre><code>&lt;a href='blah'&gt;blah&lt;/a&gt;". </code></pre> <p>So my guess is you have 2 solutions:</p> <p>1/ override the link() definition (not recommended), declaring something like:</p> <pre><code>String.prototype.link = function(url) { return "&lt;a target='_blank' href='"+url+"'&gt;"+url+"&lt;/a&gt;"; } </code></pre> <p>2/ define another function and use it instead of link() in the definition of parseURL():</p> <pre><code>String.prototype.blankLink = function(url) { return "&lt;a target='_blank' href='"+url+"'&gt;"+url+"&lt;/a&gt;"; } </code></pre> <p>Then your code should become:</p> <pre><code>String.prototype.parseURL = function() { return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&amp;~\?\/.=]+/g, function(url) { return url.blankLink(url); }); }; </code></pre> <p>To explain a bit, replace() returns the input string where parts matching the regular expression (which in this case expresses the shape of any URL) are replaced by the second argument (the unnamed function that returns url.link()). What the JS reference doesn't say is that if you give a function - instead of a string - as the second argument of replace(), then replace() will provide the currently matching part as an argument to that unnamed argument-function. Sweet mechanics, assuming this works on any browser ;)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload