title: How to get meta data from URL
body: <p>I just start to using java script and I want to fetch metadata from the URL ... when enter any URL into the input field ,it has to pull meta data from it, this is the basic usage using in html java-script when executing code throwing error</p>
  <p>I am searching any alternatives to this, but nothing helps. Please provide any idea how to achieve the functionality.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;body&gt;
      &lt;head&gt;
        &lt;meta name="description" content="Free Web tutorials"&gt;
        &lt;meta name="keywords" content="HTML5,CSS,JavaScript"&gt;
        &lt;meta name="author" content="John Doe"&gt;
        &lt;meta content="http://stackoverflow.com/favicon.ico"&gt;
      &lt;/head&gt;
      
      &lt;p&gt;Click the button to return the value of the content attribute of all meta elements.&lt;/p&gt;
      
      &lt;button onclick="myFunction()"&gt;Try it&lt;/button&gt;
      
      &lt;p id="demo"&gt;&lt;/p&gt;
      
      &lt;script&gt;
      function myFunction() {
          var x = "https://www.amazon.in/"
        // var x = document.getElementsByTagName("META");
        var txt = "";
        var i;
        for (i = 0; i &lt; x.length; i++) {
          txt = txt + "Content of "+(i+1)+". meta tag: "+x[i].content+"&lt;br&gt;";
        }
        
        document.getElementById("demo").innerHTML = txt;
      }
      &lt;/script&gt;
      
      &lt;/body&gt;
      &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>