Archive for the ‘Firefox’ Category

Reference content from chrome in Mozilla Firefox

November 28, 2009

This is a snippet of text from Working with windows in chrome code:

In case of <browser type="content-primary" />, you can use the content shortcut property to access the Window object of the content document. You can use content.document in a browser.xul overlay to access the web page in the selected tab in a Firefox window. For example:

//alerts selected text in the main content
alert(content.window.getSelection());
// alerts the title of the document displayed in the content-primary widget
alert(content.document.title);

There is no shortcut for accessing document in the sidebar. You need to use

document.getElementById(“sidebar”).contentDocument

or

.contentWindow

,

like when Accessing content documents

Works in Firefox 3.5.5.

chrome.manifest cannot be encoded in UTF-8

November 27, 2009

I am following the awesome 2X45 minute video tutorial on the Firefox “helloworld” extension bootcamp (with copy-and-paste code).

The error console kept giving me the following warning:

“Warning: Ignoring unrecognized chrome manifest instruction.
Source file: file:///D:/Profiles/smallbug1960/Projects/hellowrold/chrome.manifest Line: 1”

(There was a couple of other messages/warnings/errors underneath this one which I failed to duplicate.)

I spent “significant amount of time”- a couple of hours, to be more precise – before finally figured it out. It turned out that I had the chrome.manifest encoded in UTF-8; once I turned it in ANSI, the errors/warnings went away and the long expected “Hello world!” button finally showed up under the status bar!

BTW, I am on Windows XP Professional/Firefox v3.5.5, if that matters.