How to close a browser tab from its origin
<p>I'm able to open a new tab and then close it from its parent doing something like this:</p>

<pre><code>&lt;a id="mylink" href="javascript:" onclick="mynewwindow = window.open('https://www.google.co.in');" target="_blank"&gt;Sample Code&lt;/a&gt;
    &lt;a href="javascript:" onclick="closemywindow();"&gt;close&lt;/a&gt;
    &lt;script&gt;
        var mynewwindow;
        function closemywindow(){
            mynewwindow.close();
        }
&lt;/script&gt;
</code></pre>

<p>But if the new tab is opened through the context menu or using the scroll, how could I close that new tab?</p>