OO Javascript and this keyword. Object Literals
<p>I'm having issues with Javascript properties and "this" keyword. Forgive me here for asking my third and final JS OOP question. OOP in Javascript has been a headache for me today.</p>

<p>I'm trying to set the property 'source' but the error console is saying it's undefined in parseSource method.</p>

<p>After a little research I believe this.source is is referring to window.source? The code is a boilerplate from Mozilla. When creating extensions init is called by FireFox when the plugin is initialized.</p>

<p>What's the best way to go about setting the properties when creating objects using literal notation?</p>

<pre><code>var myExtension = {
source: null,

init: function() {  
    // The event can be DOMContentLoaded, pageshow, pagehide, load or unload.  
    if(gBrowser) {
        gBrowser.addEventListener("DOMContentLoaded", this.onPageLoad, false);  
    }
},  

onPageLoad: function(aEvent) {  
    doc = aEvent.originalTarget; // doc is document that triggered the event  
    win = doc.defaultView; // win is the window for the doc  

    // Skip frames and iFrames
    if (win.frameElement) return;

    this.source = win.document.getElementById('facebook').innerHTML;
    myExtension.parseSource();
},

parseSource: function() {
    if(this.source == null) {
        // So something
    } else {
        // Do something else
    }
}
}  

window.addEventListener("load", function() { myExtension.init(); }, false);  
</code></pre>
