3

I am submitting a form using in action=abc.pl and abc.pl contains the code for opening the new tab and loading different URL on the same page. Here is the code how I am doing (in abc.pl)

window.open('$thisPage')
window.location.href='$nextPage';

But the window.open opens in new window instead of new Tab.

monal86
  • 433
  • 2
  • 11
  • 26
  • 2
    You can't control wether `window.open` will open a new tab or a new window, that's completely up to the browser. – Marcel Korpel Mar 18 '13 at 16:15
  • But I created a dummy/test html file which will make the form submit in new tab and load different URL in old window. It works!!! – monal86 Mar 18 '13 at 16:16
  • I tried _blank, _newtab but still I get window.open in new window. I am testing it in Chrome. – monal86 Mar 18 '13 at 16:37

2 Answers2

1

as per the previous question on StackOverflow: Open a URL in a new tab (and not a new window) using JavaScript

function open_in_new_tab(url )
{
  var win=window.open(url, '_blank');
  win.focus();
}

or

$('a').click(function() {
  $(this).attr('target', '_blank');
}); 
Community
  • 1
  • 1
fizzy drink
  • 682
  • 8
  • 21
1

use second param to specify window name:

window.open('page.html','newtaborsomething');

http://www.w3schools.com/jsref/met_win_open.asp

imclickingmaniac
  • 1,467
  • 1
  • 16
  • 28