mozilla

Revision 139781 of Tabbed browser

  • Revision slug: Talk:Code_snippets/Tabbed_browser
  • Revision title: Tabbed browser
  • Revision id: 139781
  • Created:
  • Creator: Jrm
  • Is current revision? No
  • Comment /* Detecting page load */

Revision Content

Detecting page load

I rewrote this snippet to be a bit more simple

if (foo) { bar; quuz; } else { bar; }

was simplifiable to:

bar; if (foo) quuz;

I've also changed the comments to be clear about what was going on. GijsKruitbosch 11:49, 11 December 2006 (PST)


The example event handler doesn't seem to work for me with firefox 2.0 - in a .js file included from an xul overlay tag:

gBrowser.tabContainer.addEventListener("TabSelect", MSCB_changedTab, false);

gives "gBrowser has no properties"

 window.gBrowser.tabContainer.addEventListener("TabSelect", callback, false);

gives: "window.gBrowser has no properties"

I think this code needs to be inside a function that only gets run after the DOM is initialised? (eg put inside a function that is added with the window.addEventListener("load", ...))

11:57, 19 December 2006 (CET)

Revision Source

<h3 name="Detecting_page_load"> Detecting page load </h3>
<p>I rewrote this snippet to be a bit more simple
</p>
<pre class="eval">if (foo) { bar; quuz; } else { bar; }
</pre>
<p>was simplifiable to:
</p>
<pre class="eval">bar; if (foo) quuz;
</pre>
<p>I've also changed the comments to be clear about what was going on. <a href="User:GijsKruitbosch">GijsKruitbosch</a> 11:49, 11 December 2006 (PST)
</p>
<hr>
<p>The example event handler doesn't seem to work for me with firefox 2.0 - in a .js file included from an xul overlay tag:
</p>
<pre class="eval">gBrowser.tabContainer.addEventListener("TabSelect", MSCB_changedTab, false);
</pre>
<p>gives
"gBrowser has no properties"
</p>
<pre class="eval"> window.gBrowser.tabContainer.addEventListener("TabSelect", callback, false);
</pre>
<p>gives:
"window.gBrowser has no properties"
</p><p>I think this code needs to be inside a function that only gets run after the DOM is initialised? (eg put inside a function that is added with the window.addEventListener("load", ...))
</p><p>11:57, 19 December 2006 (CET)
</p>
Revert to this revision