John Jerrby John Jerrby - 11 months ago 59
Javascript Question

How to close tab without using window open

I use the following to open new tab (in new process) with some page content,

var p = document.getElementById("myElement");
var a = document.createElement('a');

When you use this code it always open new tab,
I want that when you call to this code it will see if it was a previous call that open in new tab,then it will close it and the new call will be opened in new tab.
or maybe to run the new page in the previous tab without close it.

I cannot use the regular API's ...

Answer Source

Use the same technique as in my answer here . But instead of changing the the dom in the main window just call window.close(); Example