搜尋 Mozilla 技術支援網站

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

Learn More

When using "chrome_url_overrides" in the manifest.json of my addon to change the new tab page, is it possible to focus on an element in the page?

  • 1 回覆
  • 1 有這個問題
  • 7 次檢視
  • 最近回覆由 user1321319

more options

My manifest is this:

   {
   	"manifest_version": 2,
   	"name": "Simple Startpage",
   	"version": "1.0",
   
   	"description": "My very simple start page",
   
   	"chrome_url_overrides": {
   		"newtab": "index.html"
   	}
   }

`index.html` is a normal HTML page that references an `index.js` which contains code something like this:

   window.onload = () => {document.getElementById("search").focus()}

However, when I open a new page, it focuses the address bar at the top instead of my element. Is there an approach I could take to this that would let me focus that element? Directly opening the file verifies that the focus() works.

My manifest is this: { "manifest_version": 2, "name": "Simple Startpage", "version": "1.0", "description": "My very simple start page", "chrome_url_overrides": { "newtab": "index.html" } } `index.html` is a normal HTML page that references an `index.js` which contains code something like this: window.onload = () => {document.getElementById("search").focus()} However, when I open a new page, it focuses the address bar at the top instead of my element. Is there an approach I could take to this that would let me focus that element? Directly opening the file verifies that the focus() works.

所有回覆 (1)

more options

Please visit this page for help with development questions.