1

I noticed that Gmail is not obeying my browser settings for tabs.
For ex: In Firefox3.6.10, I have unchecked the option "When I open a link in new tab switch to it immediately".
But still when I do CTRL+CLICK on a mail, it opens in a new tab and switches to it.

or

In IE8, I have selected "Always open pop-ups in a new window" but when I do CTRL+CLICK on a mail, it opens in a new tab instead of a new window.

My question is
Is it possible to override user's browser settings?

Varun
  • 4,054
  • 6
  • 31
  • 54

2 Answers2

2

I was curious about how CTRL-click and SHIFT-click work on these gmail "fake JavaScript links" myself (they appear to ignore browser settings), so I did some testing.

gmail CTRL-click does obey browser "new window/popup" settings (in Firefox the default is "open in new tab", in IE8 the default seems to be "open in new window".) If you change IE8's settings to "Always open popups in a new tab", then you get the same behaviour as Firefox. So gmail CTRL-click is very likely just using "window.open()" in JavaScript, and it's really nothing special. I seriously doubt there's any way to force a new tab to open in JavaScript. Like Yonizaf said, what you observed doesn't seem possible.

gmail SHIFT-click probably uses this method to try to always open a new window (and never a new tab) in JavaScript (window.open() with window dimensions): JavaScript open in a new window, not tab

As far as the focus thing goes, I noticed that in Firefox new gmail tabs always get the focus, regardless of the "when I open link in new tab, switch to it immediately" setting (like you said), but in IE8 the behaviour seems to be controlled by the "Always switch to new tabs when they are created" setting. I'm guessing this is probably just a result of how Firefox and IE's developers chose to handle new tabs that are created by window.open(), and there isn't much you can do about it, except as Yonizaf said, try to use the window.focus() method (I have a feeling it may not work in IE, though). In fact you can test this for yourself in Firefox and IE8 (disable your pop-up blocker first). I pasted the following URL into both Firefox and IE8 (with "Always switch to new tabs when they are created" disabled, and "Open popups in new tabs" enabled):

javascript:window.open("http://www.google.com", "_blank")

In Firefox, the new tab was opened in the foreground. In IE8, the new tab was opened in the background.

I don't like these JavaScript "fake links" personally, because you lose the middle-click and right-click functionality, and they trigger the pop-up blocker.

Community
  • 1
  • 1
Anonymoose
  • 21
  • 3
0

the first one is possible, since this options only meant to change the default behavior for links. the mail list in gmail aren't normal links, it's using javascript.

for the second example, the option can't be overriden by the webpage, but using ctrl+click always means open in new tab, so it's overriden by the user, not the page.

Yonizaf
  • 44
  • 3
  • Any example? Say I want to always open pages in a new tab. How would I achieve this in JavaScript. – Varun Nov 09 '10 at 09:34
  • for the example you provided above, you don't need it. ctrl+click will always open a new tab, since this is what it's designed to do, even with that setting you mentioned. try it with any link. rather, this one is probably impossible with javascript, i've tried gmail on IE8 and it does open the mail in a new window. not sure how you got your results – Yonizaf Nov 09 '10 at 10:03
  • for the focus example, you could use "newwindow=window.open(url);if(window.focus) {newwindow.focus()}" but it shouldn't be needed, since this option is not supposed to affect javascript at all (i.e every window opened by js will get focus) – Yonizaf Nov 09 '10 at 10:17