title: JS: How to add more than one URL into a Javascript-Code?
body: <p>I use this code in my wordpress functions.php-file to add automatically a nofollow to each link of a specific url:</p>
  
  <pre><code>function cdx_handel_external_links() {
      ?&gt;
  &lt;script type="text/javascript"&gt;
  ( function( $ ) {
  
      $("a[href^=http]").click(function(){
        if(this.href.indexOf(location.hostname) == -1) {
           $(this).attr({
              target: "_blank"
           });
        }
      })
  
     //Add Nofollow
     $("a").each(function(){
      if(this.href.indexOf('example-url.com') &gt;0 ){
          $(this).attr({
              rel: "nofollow"
           });
      }
     });
  
  } )( jQuery );
  &lt;/script&gt;
     &lt;?php
  }
  add_filter( 'wp_footer', 'cdx_handel_external_links', 999);
  </code></pre>
  
  <p>But how can I add new URLs into that code? (I am a coding noob, sry). Maybe via: 
  <code>indexOf('example-url.com','example-url2.com','example-url3.com')</code>
  ? Thank you a lot for your help!</p>
  
  <p>EDIT:</p>
  
  <p>I did it the following way as a totally noob and it works for me:</p>
  
  <pre><code>function cdx_handel_external_links() {
      ?&gt;
  &lt;script type="text/javascript"&gt;
  ( function( $ ) {
  
      $("a[href^=http]").click(function(){
        if(this.href.indexOf(location.hostname) == -1) {
           $(this).attr({
              target: "_blank"
           });
        }
      })
  
     //Add Nofollow
     $("a").each(function(){
      if(this.href.indexOf('example-url.com') &gt;0 ){
          $(this).attr({
              rel: "nofollow"
           });
      }
     });
  
   //Add Nofollow 2.domain
     $("a").each(function(){
      if(this.href.indexOf('example-url2.com') &gt;0 ){
          $(this).attr({
              rel: "nofollow"
           });
      }
     });
  
   //Add Nofollow 3.domain
     $("a").each(function(){
      if(this.href.indexOf('example-url3.com') &gt;0 ){
          $(this).attr({
              rel: "nofollow"
           });
      }
     });
  
  } )( jQuery );
  &lt;/script&gt;
     &lt;?php
  }
  add_filter( 'wp_footer', 'cdx_handel_external_links', 999);
  </code></pre>