0

and pardon my english

I have a specific problem with Chrome browser, just in chrome.

If I use a simple link, like

<a id="a1" href="http://www.stackoverflow.com" target="_blank">Need to simulate user clicking on this link, but no the onclick event</a>

The browser open the url in a new tab, so far, perfect.

My problem comes in the moment I try to do it in a javascript function.

For example, if I try to emulate the event onclick, like

$("#a1").onclick(); // Jquery is welcome

The chrome browser open a new window, and I need a tab.

So, I'm not trying to emulate the click event, just the href, I don't know how to call it. Or find the way to force in a window.open("url", "newwindow", "params", t/f );

I'm using asp.net, using an extra form to try to change the action and submit is not and option, it disappears.

For firefox and explorer I use, in a function

PopUpWindow = window.open("url", 'newWindow' + Guid, 'toolbar=0, menubar=0, location=1, status=0, scrollbars=0');

And is working well. I think I don't need the param, because the window is open as a tab.

My browser have the default settings, and I know that depending on the browser settings, you can open a window or tab by clicking the link (I checked for similar answers). So my intention is to try to emulate the href not the click event.

Or, there are any way to manage the tabs in chrome?,

Thanks in advance

ibpeco
  • 58
  • 1
  • 7
  • Why do you want to use Javascript? Generally, using JS for links is a bad mistake. If the user has disabled JS (e.g. for security or to avoid pop-ups), the links do not work. In addition, with JS links the user can not choose where to open the target, in the same window, another window or another tab. – PauliL Apr 03 '12 at 10:33
  • ref: http://stackoverflow.com/questions/143747/is-it-possible-to-trigger-a-links-or-any-elements-click-event-through-javasc – Yoshi Apr 03 '12 at 10:37
  • I use javasacript because, before to redirect I need to validate the identity in other server. In other way to say it, I have to Saas applications in two different servers, in the first one I include some features from the second, but, basically, I'm opening the second site in a new tab, once I validate the identity. – ibpeco Apr 03 '12 at 10:40
  • Yoshi: checked, but same result, still opening a new window, not new tab. – ibpeco Apr 03 '12 at 10:46

1 Answers1

0
  1. I don't think its possible, it would be against all browser rules to force open a tab.

  2. Tabs are a setting in your browser, not every user wants to use tabs. It's almost always better to let the user control this kind of behavior instead of forcing this upon them.

To open a new window (or tab if the user set this in his/her settings) use:

window.open(
  url,
  '_blank' // new window or tab.
);
Tim
  • 9,351
  • 1
  • 32
  • 48
  • Agree @Tim. The user is the one who _"knows"_ how to setup his/her browser. Just trying to not to bhoter with new windows. Thanks – ibpeco Apr 03 '12 at 11:15