Tabbed browser

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

Revision Content

Simplified code in "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)

gBrowser has no properties

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)

If you read the page closer, you'll see it mentioned in the introduction. Feel free to rearrange the article to make this more obvious. --Nickolay 08:37, 19 December 2006 (PST)

Revision Source

<h3 name="Simplified_code_in_.22Detecting_page_load.22"> Simplified code in "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>
<h3 name="gBrowser_has_no_properties"> gBrowser has no properties </h3>
<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>
<dl><dd> If you read the page closer, you'll see it mentioned in the introduction. Feel free to rearrange the article to make this more obvious. --<a href="User:Nickolay">Nickolay</a> 08:37, 19 December 2006 (PST)
</dd></dl>
Revert to this revision