# Closing the new tab automatically

**URL:** <https://discourse.jupyter.org/t/closing-the-new-tab-automatically/13870>\
**Category:** Notebook\
**Created:** [April 13, 2022, 11:47pm UTC](https://discourse.jupyter.org/t/closing-the-new-tab-automatically/13870 "2022-04-13T23:47:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![KhaoulaSoussi](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/khaoulasoussi/32/6310_2.png) [@KhaoulaSoussi](https://discourse.jupyter.org/u/KhaoulaSoussi)\
**Post date:** [April 13, 2022, 11:47pm UTC](https://discourse.jupyter.org/t/closing-the-new-tab-automatically/13870/1 "2022-04-13T23:47:06Z")

</div>

Hello dear community,  
I implemented a slight change to a function to achieve the automatic closing of an opened tab. I did achieve the wanted outcome, but I still cannot figure out the difference between the implementation I wrote, and the original implementation. Basically, when the user clicks the download as (exporter) option in the notebook, a new tab is opened; this tab is not closed automatically after the notebook is exported. Ideally, we want to close the tab automatically after the conversion is done, I could achieve this by making a slight change to the \_new\_window() function in the menubar.js module. Here is the original implementation and the new implementation of the method:  
Original: Does not close the tab automatically:

```auto
MenuBar.prototype._new_window = function(url) {
        var w = window.open('', IPython._target);
        if (this.notebook.dirty && this.notebook.writable) {
            this.notebook.save_notebook().then(function() {
                w.location = url;
            });
        } else {
            w.location = url;
        }
    };

```

New: The tab is closed automatically

```auto
MenuBar.prototype._new_window = function(url) {
        if (this.notebook.dirty && this.notebook.writable) {
            this.notebook.save_notebook().then(function() {
                window.open(url, IPython._target);
            });
        } else {
            window.open(url, IPython._target);
        }
    };

```

Please do you have any idea why the first implementation did not close the tab? And what makes the second implementation different. Thank you,
