title: Window navigator standalone and event listener - Javascript
body: <p>I am new in Javascript. I am trying to study and understand the following part of code:</p>
  
  <pre><code>if(("standalone" in window.navigator) &amp;&amp; window.navigator.standalone){ //1
  
     var node = false;
  
     document.addEventListener('click', function(event) {
  
     node = event.target;
  
     while(node.nodeName !== "A" &amp;&amp; node.nodeName !== "HTML") {
     node = node.parentNode;
     }
  
     if('href' in node &amp;&amp; node.href.indexOf('http') !== -1 &amp;&amp; 
     (node.href.indexOf(document.location.host) !== -1)){
  
        event.preventDefault();                                
        document.location.href = node.href;        }                  
      },false);
    }
  </code></pre>
  
  <p>Now, imagine following: you are on a page <a href="http://test.gr/index.html" rel="nofollow noreferrer">http://test.gr/index.html</a> and the first condition is true (//1.). There is this link on the page:</p>
  
  <pre><code>&lt;a href="http://test.gr/info.html" target="_blank"&gt;Info&lt;/a&gt;  
  </code></pre>
  
  <p>1) Under which circumstances the first condition (//1) is true?</p>
  
  <p>2)What happens after clicking on the link? When the code pass the while loop? Does the link open in the same tab or in a new tab?</p>
  
  <p>Thanks</p>