2

I just want to open all pages in new tabs... Is it about chrome or my codes? Before formatting computer i can do that with this code, but now the first link open in new tab and the others open in new window. I think some of my chrome options are broken or something...

for (var i = 0; i < 2; i++) {
    window.open(document.getElementById("threads").getElementsByClassName("title")[i].getAttribute("href"));
}
Carl Smith
  • 3,025
  • 24
  • 36
Khloros
  • 45
  • 2
  • 7
  • Possible duplicate: http://stackoverflow.com/questions/4907843/open-url-in-new-tab-using-javascript – Boaz Feb 11 '13 at 12:56
  • this link might be help full... http://stackoverflow.com/questions/12235585/is-there-a-way-to-open-all-a-href-links-on-a-page-in-new-windows – Kingk Feb 11 '13 at 12:56

1 Answers1

0

If you are writing a Chrome extension then you can use the chrome.tabs API:

chrome.tabs.create({ url: "http://www.google.com/" });

See the documentation at: http://developer.chrome.com/extensions/tabs.html

To people who vote to close this question:

All of the linked "Possible duplicate" questions are browser-agnostic and all of the answers say that doing that is impossible. This question on the other hand is Chrome-specific and there is a Chrome-specific API that can be used to do just that for Chrome extensions. So I wouldn't say that this question is a duplicate or that the answers to linked questions are particularly relevant.

rsp
  • 107,747
  • 29
  • 201
  • 177
  • 2
    According to the code the asker posted I highly doubt that he is creating extension for google chrome. The other linked question DO solve issues with chrome too. (just have look in the second in my list) – Tomáš Zato Feb 11 '13 at 13:27
  • @rsp There are other no less important criteria - the question is very unclear and barely readable. Your answer probably belongs in one of the other threads. If you don't agree, why not edit the OP to try to make it more up to standard? – Boaz Feb 11 '13 at 13:31
  • `-1` The OP doesn't want to do a Chrome Extension; they want Chrome "to open all pages in new tabs". Your answer is mostly just a comment on whether this is a dupe. No hard feelings, but this answer is pretty poor, and you have 14k rep, so this must be way below your own normal standards. I deleted my own answer with 3 upvotes too, as it had just become cruft. Chrome just opens new tabs as you'd expect these days anyway. – Carl Smith Jun 07 '15 at 21:13