Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

how to override new tab url using javascript

  • 4 replies
  • 2 have this problem
  • 8 views
  • Last reply by cor-el

more options

how can I manipulate the file associated with new tab to alter the displaying tile content using javascript or similar, otherwise redirect to a different page. Note: Don't want to use any Add on as I want to create one....

how can I manipulate the file associated with new tab to alter the displaying tile content using javascript or similar, otherwise redirect to a different page. Note: Don't want to use any Add on as I want to create one....

All Replies (4)

more options

"Note: Don't want to use any Add on as I want to create one.... "

Try asking in the Addon support fora. https://discourse.mozilla-community.org/c/add-ons

more options

Thank you for introducing me to the forum. I just want to inject HTML in the new tab page. Still looking for answers.

more options

Beyond the scope of this user support forum. That is a topic best address by add-ons support or a developer forum. https://support.mozilla.org/en-US/kb/where-go-developer-support


First it was Javascript or an extension that you want to create; now it's HTML. The "page" you want to modify is about:newtab an internal page. You need to start at the beginning, by reading how Firefox "creates" the "about:" protocol internal pages which is done using XUL, not HTML. This developer lists all the "about:" internal "pages". https://developer.mozilla.org/en-US/Firefox/The_about_protocol You'll need to fo from there and search MDN to find the appropriate information.

And IMO now is not the time to learn about development for Firefox, as the coding used to display that "about:" pages will be completely different in Firefox 57 - 6 versions (~ 48 weeks) from now. A new way of coding about:newtab will be used them; along with learning the new way of modifying the newtab page.

Modified by the-edmeister

more options

You can do this via the mozilla.cfg file in the Firefox program folder. See Configuration:

I use this method all the time with all Firefox versions.

// resource:///modules/NewTabURL.jsm
var newTabURL = "about:blank";
Components.utils.import("resource:///modules/NewTabURL.jsm");
NewTabURL.override(newTabURL);

You can use these commands in the Browswer Console to get/set the current new tab setting. The Cu.import line is only needed once when you get an error, Cu is short for Components.utils.

Cu.import("resource:///modules/NewTabURL.jsm");
NewTabURL.get();

You can use this command to set the new tab URL:

Cu.import("resource:///modules/NewTabURL.jsm");
NewTabURL.override("about:blank");

You can use the mozilla.cfg file in the Firefox program folder to set or lock preferences and run privileged JavaScript code.

A local-settings.js file needs to be placed in the "defaults/pref" folder where also the channel-prefs.js file is located to specify using mozilla.cfg.

pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);

These functions can be used in the mozilla.cfg file:

defaultPref();	// set new default value
pref();		// set pref, allow changes in current session
lockPref();	// lock pref, disallow changes

The mozilla.cfg and local-settings.js files need to start with a comment line (//).

See also: