0

Adding target="_blank" to form will post & open the result in a new tab (or window).

<form target="_blank" enctype="multipart/form-data" 
      action="https://www.example.com/" method="POST">
  <!-- more HTML -->
</form>

// and from the addon form.submit();
// there isn't any button or link to be clicked by the user

By default, the new tab will be the selected/foreground tab.
Is it possible to control/set the foreground/background status of the new tab?

N.B. The purpose is to give the USER the choice of opening in the foreground or background by using a modifier key (like for example shift or Ctrl).

The code is part of a Firefox addon (not part of site JavaScript).

erosman
  • 7,094
  • 7
  • 27
  • 46
  • 1
    I can only imagine this would be very bad in terms of evil people doing evil things and hence you cannot control that – PeeHaa Jul 31 '14 at 12:23
  • possible duplicate of [I need to to open a new window in the background with JavaScript, and make sure the original is still focused](http://stackoverflow.com/questions/2181464/i-need-to-to-open-a-new-window-in-the-background-with-javascript-and-make-sure) or [How to open link in new windows by _blank and in background?](http://stackoverflow.com/questions/9544519/how-to-open-link-in-new-windows-by-blank-and-in-background) or [Open a new tab in the background?](http://stackoverflow.com/questions/10812628/open-a-new-tab-in-the-background) and probably a lot more dupes – PeeHaa Jul 31 '14 at 12:25
  • @PeeHaa ... I understand the concern. The purpose is to give the USER the choice, ie by holding shift key or other modifier. I will add this to the original question. – erosman Jul 31 '14 at 12:32
  • There already is such a thing (at least in Chrome): ctrl + click – PeeHaa Jul 31 '14 at 12:38
  • I just checked and on win FF it works the same. ctrl+click opens new tab in background – PeeHaa Jul 31 '14 at 12:44
  • @PeeHaa tnx ... Did you check it with a link or a form? – erosman Jul 31 '14 at 12:46
  • Tried a link in FF and form in chrome. Apparently FF doesn't allow it in form :( – PeeHaa Jul 31 '14 at 12:58
  • For XUL windows you can use this method here: [GitHubGIST :: Noitidart / _ff-addon-snippet-OpenXULWindowBehind.js](https://gist.github.com/Noitidart/9b9ef5460a9a8b024324) – Noitidart Jul 31 '14 at 15:25
  • However to do this with a form click, maybe you should listen to tab open and on open if its the location you expect than switch to tab before it. Or temporarily set all new tabs to open in background then open the tab then revert the setting to user default – Noitidart Jul 31 '14 at 15:27
  • 2
    i nominate to re-open, this is different from linked answers as its in the firefox addon scope. – Noitidart Jul 31 '14 at 15:27
  • @Noitidart ..Tnx.. it was in Firefox Addon scope but got diverted to nowhere (with a dup label). I gave up looking for answers and went back to my own testing and manged it in a totally different way with gBrowser (much easier, 2 lines, testing now). ;) – erosman Jul 31 '14 at 18:25
  • @erosman Please share that man in this topic here: http://stackoverflow.com/questions/25063835/how-to-control-opening-of-next-link?lq=1 – Noitidart Jul 31 '14 at 22:06

0 Answers0