Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

How to set focus on newtab page and not the url bar

  • 4 trả lời
  • 0 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi n6v26r

more options

When I open a new tab, i would like the page to be in focus and not the urlbar. This is what i used to have in my mozilla.cfg: ``` // Auto focus new tab content try {

 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource:///modules/BrowserWindowTracker.jsm");
 Services.obs.addObserver((event) => {
   window = BrowserWindowTracker.getTopWindow();
   window.gBrowser.selectedBrowser.focus();
 }, "browser-open-newtab-start");

} catch(e) { Cu.reportError(e); } ``` This worked until the last update. What solutions are there?

When I open a new tab, i would like the page to be in focus and not the urlbar. This is what i used to have in my mozilla.cfg: ``` // Auto focus new tab content try { Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource:///modules/BrowserWindowTracker.jsm"); Services.obs.addObserver((event) => { window = BrowserWindowTracker.getTopWindow(); window.gBrowser.selectedBrowser.focus(); }, "browser-open-newtab-start"); } catch(e) { Cu.reportError(e); } ``` This worked until the last update. What solutions are there?

Giải pháp được chọn

Services is now a global variable and you can no longer use Cu.import. You need to remove all thes lines.

Cu.import("resource://gre/modules/Services.jsm");

You can this instead in older (e.g. 115 ESR) and newer (117+) Firefox versions.

const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;

Đọc câu trả lời này trong ngữ cảnh 👍 1

Tất cả các câu trả lời (4)

more options

Giải pháp được chọn

Services is now a global variable and you can no longer use Cu.import. You need to remove all thes lines.

Cu.import("resource://gre/modules/Services.jsm");

You can this instead in older (e.g. 115 ESR) and newer (117+) Firefox versions.

const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;

more options

Hey! I know this isn't related to the original question, but is there a way to also do this for the startpage?

more options

The search bar you see on the Firefox Home page is not a real search bar, but is a fake search bar and even the cursor is fake as you can see if you check this in the inspector (right-click: Inspect), even the For now there is a pref to revert this change.

  • about:config => browser.newtabpage.activity-stream.improvesearch.handoffToAwesomebar = false
more options

Hmmm. I don't think that does It. I was talking about the url bar, not the search bar on the page. I think this is specific to me. I forced a different new tab page in mozilla.cfg and applied the patch above for cursor focus. It appears that when the startpage has the same url, the cursor doesn t focus corectly. So, for now, setting one with file:// and one without, magically worked.