Close Current Tab

close current tab javascript
close current tab and open new tab in javascript
close current tab jquery
javascript close current window chrome
close current tab in asp.net c#
close tab shortcut chrome
javascript close browser
close tab shortcut mac

I have a close link on my web page. I would like to function it to close the current tab when click it. I have written

<a href="#" onclick = "javascript:self.close();">close</a>

The above code seems to be working well in Internet Explorer. But it is not working in Mozilla Firefox and Google Chrome. Please help me to resolve this.


You can only close windows/tabs that you create yourself. That is, you cannot programmatically close a window/tab that the user creates.

For example, if you create a window with window.open() you can close it with window.close().

4 Ways to Close Windows, You will need Javascript to do this. Use window.close() : close();. Note: the current tab is implied. This is equivalent: window.close();. or you can  You can use Internet Explorer on Windows 10, which will ask you if you want to close the current tab. To find it: 1. Open the Start menu. 2. Click All Apps. 3. Expand the Windows Accessories folder, and click Internet Explorer. You can also drag its icon to the taskbar to pin it there. I do not recommend Microsoft Edge.


As of Chrome 46, a simple onclick=window.close() does the trick. This only closes the tab, and not the entire browser, if multiple tabs are opened.

How to close current tab in a browser window?, Close the current tab, Hold Command and press W. Reopen last tab closed, Hold Command and Shift, then press T. View next tab, Hold  Press Ctrl + W (Windows) or ⌘ Command + W (Mac) on your computer's keyboard to close the tab you're currently using. Make sure you're on the tab that you want to close before doing this. 3 Close all tabs in a browser.


You can use below JavaScript.

window.open('','_self').close();

In a HTML you can use below code

<a href="javascript:close_window();">close</a>

I have tried this in Chrome 61 and IE11 it is working fine. But this is not working with Firefox 57. In Firefox we can only close, windows which opened using below command.

window.open()

The 33 Most Useful Keyboard Shortcuts for Google Chrome, Note: A current window/tab will only get closed if and only if it was created & opened by that script.Means the window.close syntax is only allowed for the window/  Open a new tab: Hold Command and press T: Close the current tab: Hold Command and press W: Reopen last tab closed: Hold Command and Shift, then press T: View next tab: Hold Command and Option, then press the right arrow key: View previous tab: Hold Command and Option, then press the left arrow key: Jump to a specific tab: Hold Command and


Found a one-liner that works in Chrome 66 from: http://www.yournewdesigner.com/css-experiments/javascript-window-close-firefox.html

TLDR: tricks the browser into believing JavaScirpt opened the current tab/window

window.open('', '_parent', '').close();

So for completeness

<input type="button" name="close" value="close" onclick="window.close();">

Though let it also be noted that readers may want to place this into a function that fingerprints which browsers require such trickery, because Firefox 59 doesn't work with the above.

How to close current tab in a browser window using JavaScript , You must work with Javascript, try using window.close():. close();. Note: The above code is applicable only for the current tab. This is equivalent  Internet Explorer 11 Press this in Internet Explorer for the desktop; Add current site to favorites. Ctrl + D. Crtl + D. Close tab. Ctrl + W. Ctrl + W. Go to your home page (Not available) Alt + Home. Delete browsing history (Not available) Ctrl + Shift + Delete. Get help & support. F1. F1. Open browsing history (Not available) Ctrl + H. Open a


Try this:

<script>
    var myWindow = window.open("ANYURL", "MyWindowName", "width=700,height=700");
    this.window.close();
</script>

This worked for me in some cases in Google Chrome 50. It does not seem to work when put inside a javascript function, though.

How to close current tab in a browser window?, This shortcut saves you from needing to click the little X to close a tab. Instead, use Command-W to close your current tab. Likewise, instead of  I have an ASP.NET MVC app that opens a "Request" view in a new browser window. When the user submits the form, I'd like the window to close. What should my RequestController code look like to close


21 Chrome shortcuts you need to know, open() method. Now suppose you want to create a link that will close the current tab when it will be clicked. To do that lets first create our HTML link 


Close current tab in browser window using JavaScript, close() . For example, the following will close the current window/tab. <script type​="text/javascript"> window.close() ;


How to Close a Browser Tab/Window with JavaScript (thesitewizard , How can we can close the close current tab in a browser window using JavaScript? DanCouper January 18, 2020, 4:03pm #2. As long as the