搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

What's the name of the pref to automaticly "switch to this tab" when a popup firing on tab (B) when I'm on another tab (A)

  • 13 回覆
  • 1 有這個問題
  • 83 次檢視
  • 最近回覆由 romain.johan

more options

Hi,

I would like to set this pref to TRUE by default with the use of user.js file but I can't find the name of the pref related to this behaviour :

I'm on a window. I click on a link. Before it fully load, i get back on my first tab. The opened tab fired up a popup to inform me of something.

I would like to be automaticly redirected on this tab without having to manually press the checkbox on the dialog popup.

There must be a preference to add to user.js in my profile folder to set it to TRUE.

Thank's

Hi, I would like to set this pref to TRUE by default with the use of user.js file but I can't find the name of the pref related to this behaviour : I'm on a window. I click on a link. Before it fully load, i get back on my first tab. The opened tab fired up a popup to inform me of something. I would like to be automaticly redirected on this tab without having to manually press the checkbox on the dialog popup. There must be a preference to add to user.js in my profile folder to set it to TRUE. Thank's
附加的畫面擷圖

被選擇的解決方法

Services.perms.add() is no longer supported.

You need to use Services.perms.addFromPrincipal()

Services.perms.addFromPrincipal(
  Services.scriptSecurityManager.createContentPrincipalFromOrigin("https://xxx.com"),
  "popup", 1
);

See also: 從原來的回覆中察看解決方案 👍 0

所有回覆 (13)

more options

That is about this pref: browser.tabs.loadInBackground

These prefs on the about:config page control whether links are opened with a left-click in the background or get focus:

  • browser.tabs.loadInBackground (normal links)
  • browser.tabs.loadDivertedInBackground (javascript and external links)
  • browser.tabs.loadBookmarksInBackground (bookmarks)
  • browser.search.context.loadInBackground (context menu: Search)

Note that it is easier and safer to use a autoconfig.cfg and autoconfig.js file to control prefs.

more options

Hi romain. johan, I'm not sure I understand exactly what you are looking for.

  • I'm on a window.
  • I click on a link.
  • Before it fully load, i get back on my first tab.
  • The opened tab fired up a popup to inform me of something.
I would like to be automaticly redirected on this tab without having to manually press the checkbox on the dialog popup.

On the third step, you switched between the two tabs, not Firefox, is that correct?

I think the alert dialog in the new tab is only "tab modal" meaning Firefox would not require you to give it your attention when you are on a different tab. Is that how yours works, Firefox does not switch to the new tab automatically?

I'm not sure what you need with the bolded part of the last sentence. On the U.S. English version, I think that checkbox tells Firefox not to allow any more alert() dialogs from the page after this one. On yours, is it the same, or is yours the other way around, you need to check the box to allow more dialogs (you want more dialogs)?

(Note for possible future research: dom(dot)successive_dialog_time_limit might be relevant?)

由 jscher2000 - Support Volunteer 於 修改

more options

Is it already possible to post pref names and filenames ?

more options

cor-el said

Is it already possible to post pref names and filenames ?

Still in staging.

more options

I will try to explain better.

I'm on a page. I click on a link. It creates a new tab (let's call it 'tabpopup'). This tab will inform me of something related to the application, with an alert box, soon but before it does that, i switch back to my first tab, or any other tab to continue working on other things. By default, the popup will show on 'tabpopup' and inform me correctly but I won't be redirect on this tab. I will remain on my current tab and only be informed that there was a popup when I manually go back on 'tabpopup'.

There is also a new line on this popup with a checkbox. This message in this case ask me if I want this kind of behaviour or if I prefer to be automaticly switched back on the tab when a popup shows up.

Translate of the line in front of the checkbox : 'Allow dialogs from 'blablabla' to move to their tab'

What I want to know is if there is a preference that automaticly 'checks this checkbox' to get the second behaviour : Be switched back on the tab that silently fired a popup to be informed as soon as possible of this message.

I tried to check manually the checkbox and find the new pref added on the prefs .js file but couldn't find it.

The information should be stored somewhere as a preference but which one ?

more options

It is a per-site preference (Switch to this Tab), so you can't find it in prefs.js.

more options

TyDraniu said

It is a per-site preference (Switch to this Tab), so you can't find it in prefs.js.

I did not know about that. I do see it in the Page Info dialog, so when you are on the site that should have permission, you can call up Page Info using either:

  • Ctrl+i (for Mac, Command+i)
  • right-click a blank area of the page > View Page Info
  • (menu bar) Tools > Page Info

When the dialog comes up, click the Permission icon at the top to show that panel.

Then scroll down to the "Switch to this Tab" permission (I don't know what it will be called in your language), uncheck the "Use default" box and select the permission you prefer.

more options

Ok thank's for all these replies.

My goal was to find a way to do it automaticly by using a preference. I can't manually check it on every computer on which Firefox would be installed.

If there isn't any preference attached to this checkbox and that's it's only a per-site preference on which we don't have control other than manually on the menu you showed, then this thread is closed :)

Can I have confirmation that there isn't any solution to have this option (Switch to this tab) set to "Allow" by default ?

more options

I don't think so because I don't see a relevant preference starting with

permissions.default

I also don't see it on the policy list:

https://github.com/mozilla/policy-templates#permissions

more options

You might be able to do "focus-tab-by-prompt" via an autoconfig.cfg file.

You need to disable the sandbox via autoconfig.js to be able to use JavaScript in non ESR builds.

This is basic code for older Firefox versions that still might work (not tested) as things have been moved to SitePermissions.jsm.

Components.utils.import("resource://gre/modules/Services.jsm");
var uri = Services.io.newURI("https://example.com", null, null);
var PERMISSION = ["cookie","desktop-notification","login-saving","popup","safe-browsing","trackingprotection","focus-tab-by-prompt","microphone","camera"];
var ACTION = ["Services.perms.UNKNOWN_ACTION","Services.perms.ALLOW_ACTION","Services.perms.DENY_ACTION"];
Services.perms.add(uri, PERMISSION[6], ACTION[1]);

由 cor-el 於 修改

more options

Hi,

I tried your solution but i'm getting this error in the console (CTRL + SHIFT + J on windows)

Services.perms.add is not a function

My autoconfig.cfg file is therefore not loaded. I'm on an ESR build (ESR 78)

Where am I wrong ?

由 romain.johan 於 修改

more options

選擇的解決方法

Services.perms.add() is no longer supported.

You need to use Services.perms.addFromPrincipal()

Services.perms.addFromPrincipal(
  Services.scriptSecurityManager.createContentPrincipalFromOrigin("https://xxx.com"),
  "popup", 1
);

See also:
more options

Thank's a lot, it's working like a charm. This thread can be marked as resolved now.