Skip to content

Instantly share code, notes, and snippets.

@scryptonite
Last active December 16, 2015 09:59
Show Gist options
  • Save scryptonite/5417139 to your computer and use it in GitHub Desktop.
Save scryptonite/5417139 to your computer and use it in GitHub Desktop.
close.js

close.js

Closes the current window (or popup).

Usage

window.close(); // current window is closed.
close(); // current window is closed.
close.call(window); // current window is closed.

var popup = window.open();
close.call(popup); // popup is closed.
window.close = (function(close){
return function(){
return close.call(
this.open("about:blank", this.name = Math.random())
);
}
})(window.close);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment