I have a small bit of javascript intended to open two or more tabs. This works fine in FF and IE, but chrome opens the second one in a new window instead of tab. It isn\'t d
I came across this question What is the (function() { } )() construct in JavaScript? which gives explanation on IIFE. I think this can be used over. Please bear with me I don't have deep knowledge about javascript. But I tried as below and its working.
var sites = [{"url" : "http://www.google.com"} , {"url" : "http://www.yahoo.com"} , {"url" : "http://www.msn.com"}];
console.log(sites);
for( var i=0 ; i < sites.length ;i++) {
(function(i) {
console.log(i);
window.open(sites[i].url , "_blank");
})(i);
}
It opens the url in new tabs in chrome.