Take the 2-minute tour ×

I'm making a personal script to search google in another language and I've got a url that I've passed from a php script. I want to use jquery to open that url in a new tab (only in google chrome).

I tried:

  window.open("http://localhost/123", '_blank');

It unfortunately Opens in a new window in google chrome, which is unfortunately the only browser that's light enough to use on my computer. I don't seem to have any success googling it so any advice would be much appreciated.

Thanks Sam

EDITED: Sorry if your not meant to edit like this but my new question is (I should probably ask it somewhere else):

How to edit google chromes config to open a new tab instead of a window when window.open("href", "_blank") is called?

share|improve this question
it works if I use a link a href="asd" target="_blank", I'm just about to look on the google website for more info –  killkrazy Oct 23 '11 at 16:11
possible duplicate of How do you open a new tab in chrome using HTML/JS? –  Jon Oct 23 '11 at 16:12
How would I go about changing my google chrome to allow window open to go into a new tab? –  killkrazy Oct 23 '11 at 16:17
Also possible duplicate: Programmatically open new pages on Tabs –  mc10 Oct 23 '11 at 17:36

3 Answers 3

up vote 4 down vote accepted

You can't directly control this, because it can be configured by the user. You might try "_newtab" which might work for Firefox but really you shouldn't rely on a new tab being opened. The user may have their browser settings set to open a new tab when a popup window is opened or it may show up as a popup. It just all depends on the browser settings.

share|improve this answer
I would just rather be able to click go and to have google search in australia without having to click on another link –  killkrazy Oct 23 '11 at 16:18
Could I change the browser settings? –  killkrazy Oct 23 '11 at 16:19
<a href="#" onclick="newTab();">Test</a>

  function newTab()
     window.open('www.google.com', '_blank', 'toolbar=0,location=0,menubar=0');
share|improve this answer
in that case, it would've been much better to use <a href="http://google.com" target="_blank">Test</a> than inline script. Correct me if I am wrong, but your code will give a "pop-up blocked" error. –  R.D. Oct 23 at 16:56
`$(document).ready(function() {
   $('#NewTab').click(function() {
        $(this).target = "_blank";
        return false;

share|improve this answer

Your Answer


