Loading Urls

ThunderBrowse also allows extensions to load urls. ThunderBrowse ports a lot of Firefox functions to Thunderbird so extension developers can add support for both applications easily and without lots of additional code.

Ways to load

There are several ways to load urls (but the following are just the easiest).

browsetothrufield(url,historyflag,specificBrows,referUrl,postData)
getBrowser().loadURI(url,referrerUrl,postData) [3.2.1.6 and above]
openUILinkIn(url, where, allowThirdPartyFixup, postData, referrerUrl) [3.2.6 and above]

getBrowser().loadURI and openUILinkIn are both Firefox functions.

General Note

3.2.6 adds a lot of new flags to these functions, and many of these flags are not available in version before 3.2.6. It is advised that you use the specific section url methods. A forwards compatibility addon is planned for versions before 3.2.6.

If you want to support Firefox and Thunderbird and load urls into both, you can use getBrowser().loadURI(url); where url is the web address you want to load. This function is available in both Firefox and ThunderBrowse, so you don’t need to worry about conflicts. This function is not defined in ThunderBrowse versions before 3.2.1.6, so you will have to add a version check. See Checking ThunderBrowse Versions.

If you want to support just Thunderbird, you would use browsetothrufield(url);. url is the web address you want to load. This function is available in all ThunderBrowse versions. The name of the main function will change in future versions (but it will be backwards compatible).

Using each function

browsetothrufield(url,historyflag,specificBrows,referUrl,postData)

url is the url of the website to load

historyflag is an internal argument. It must ALWAYS be null

specificBrows is the xul browser element the url should load in [3.2.4 and above]

referUrl is the url of the referrer document. Does not show mail urls. [3.2.6 and above]

postData is if you want to make the load a  POST request (you will need to character encode your data. See the formatting notes at the bottom of this page)  [3.2.6 and above].

getBrowser().loadURI(url,referrerUrl,postData)

url is the url of the website to load

referrerUrl is the url of the website before [new in 3.2.6]

postData is if you want to make the load a  POST request (you will need to character encode your data. See the formatting notes at the bottom of this page) [3.2.6 and above].

openUILinkIn(url, where, allowThirdPartyFixup, postData, referrerUrl)

url is the url of the website to load

where is a string based name to where the object should load. Accepted strings are:

  • “current” current tab/browser
  • “tab” new ThunderBrowse tab
  • “tabshifted” is the same as “tab” but is loaded in the background if the user default is to focus new tabs and vice versa
  • “window” loads a new ThunderBrowse window
  • “save” and “file” save the url to disk

allowThirdPartyFixup is a bool argument that tells ThunderBrowse if it should do an “I’m feeling lucky search” if it cannot resolve the url (this has not been implemented as of 3.2.6).

postData is if you want to make the load a  POST request (you will need to character encode your data. See the formatting notes at the bottom of this page) [3.2.6 and above].

referrerUrl is the url of the referrer document. Does not show mail urls.

Formatting notes

Referrer URLs can be easily formatted via sending the string of the url to TbrowseDev.formatRefUri() as an argument. Returns the url as a formatted nsIUrl.

Formatting postData can be done by sending the post data (for example: q=google&hl=1) as a string to ThunderBrowseHandler.handlePostData().

See Also

Working with Tabs

Checking ThunderBrowse Versions