As you are writing an add-on for Firefox, you should know that Firefox itself is a great program written in JavaScript and XUL (its weird markup language, which serves, in a way, as face-oriented HTML native and with many more components). Well, when you click the extension button, the current document is the Firefox window itself, so it will display the XUL source code of the window.
I assume your JavaScript code looks something like this:
var seesource = {
run : function(aEvent) {
alert(document.documentElement.outerHTML);
}
};
Fortunately, the scope of the scripts will contain a variable called content
, which will reference the contents of the current tab. The key is to get the document
of this variable:
var seesource = {
run : function(aEvent) {
alert(content.document.documentElement.outerHTML);
}
};
See the result
This,however,doesnotapplyifyouareusingthe Addon SDK , the modern way of developing add-ons. In this case, the thing will be a little more complicated but it is clearly not your case.