Reputation: 3
var mywin = null;
var mywin1 = null;
var mywin2 = null;
var mywin3 = null;
chrome.browserAction.onClicked.addListener(function () {
if (mywin == null || mywin.closed) {
mywin = window.open('https://google.com');
} else {
mywin.focus();
}
if (mywin1 == null || mywin1.closed) {
mywin1 = window.open("https://facebook.com");
} else {
mywin1.focus();
}
if (mywin2 == null || mywin2.closed) {
mywin2 = window.open("https://youtube.com");
} else {
mywin2.focus();
}
if (mywin3 == null || mywin3.closed) {
mywin3 = window.open("https://gmail.com");
} else {
mywin3.focus();
}
});
this code avoid the duplicate new tab when tab already open but this code work correctly when click but after some time i try to click it will open all tab again pls help me
Upvotes: 0
Views: 62
Reputation: 397
Pass the second argument name
to the window.open("http://facebook.com", "fbwin");
More on window.open can be found here ... http://www.w3schools.com/jsref/met_win_open.asp
Upvotes: 2