J Bruck
J Bruck

Reputation: 13

Change the current URL of a specific Firefox tab

I have a Firefox add-on that intercepts HTML requests, exactly as outlined in the Mozilla tutorial here. Whenever it intercepts a request it calls a callback function logURL(details) where details contains the tabId of the tab that originated the request (among other things).

What I would like to be able to do is modify the tab that originated the request, specifically to set its URL to something new. Everything I've found that seems vaguely related to this task on the Mozilla website (e.g. this) has been marked obsolete.

How can you set a tab's URL to something new given its tab ID within an add-on?

Upvotes: 1

Views: 447

Answers (1)

Makyen
Makyen

Reputation: 33376

This is one of the things which can be done with tabs.update(). If you want to navigate the tab with the ID tabId to the URL contained in newUrl, then you could do the following:

chrome.tabs.update(tabId,{url: newUrl});

Upvotes: 1

Related Questions