<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Michael Sync &#187; Firefox</title>
	<atom:link href="http://michaelsync.net/category/firefox/feed" rel="self" type="application/rss+xml" />
	<link>http://michaelsync.net</link>
	<description>Sharing our knowledge</description>
	<lastBuildDate>Thu, 05 Apr 2012 07:37:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Firebug Tutorial : Section 4 &#8211; Net, CSS and DOM tabs</title>
		<link>http://michaelsync.net/2007/10/15/firebug-tutorial-section-4-net-css-and-dom-tabs</link>
		<comments>http://michaelsync.net/2007/10/15/firebug-tutorial-section-4-net-css-and-dom-tabs#comments</comments>
		<pubDate>Mon, 15 Oct 2007 17:58:14 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2007/10/15/firebug-tutorial-section-4-net-css-and-dom-tabs</guid>
		<description><![CDATA[This is the last post of Firebug tutorial series. I&#8217;m going to explain about Net panel, CSS panel and DOM panel in this tutorial. As there are not so much things to say about that, I&#8217;m gonna write up about...]]></description>
			<content:encoded><![CDATA[<p>This is the last post of Firebug tutorial series. I&#8217;m going to explain about Net panel, CSS panel and DOM panel in this tutorial. As there are not so much things to say about that, I&#8217;m gonna write up about all three panels in one post.</p>
<p><u><strong>#1. Net Panel</strong></u></p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/net-panel-toolbar.jpg" alt="Net Panel - Firebug" /></p>
<p>The <strong>Net Panel</strong> can be used for measuring the performance of your webpage. It shows very useful informations about how long your webpage takes to load, the size and loading time of each and every files (i.e: image files, css, js file and so on.)  of your webpage.  if you are looking for the way to improve the performance of your webpage, you just need to check the NET panel after loading your page and see which files took so long to load.</p>
<p><strong>1.1. What is Net panel showing?</strong></p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/net-panel-preview.jpg" /></p>
<p>Let&#8217;s take a lot what kinda information NET panel shows  for you. There are four columns in NET panel.</p>
<ol>
<li><strong>Name of files</strong> : The first column at the left-side shows the name of each and every files that are included in your webpage.</li>
<li><strong>Base URL</strong> : The second column shows the base URL  of  each file. If you are using  some files from other sites  (eg: linking image from other site, putting ads in your blog ) then the different  URL(s) will be shown in this column.</li>
<li><strong>Size</strong> : The third column shows the size of each file.</li>
<li><strong>Loading Time</strong> : The last column shows the loading time of each file and whether those files are loaded from cache or not. It also show the status of each file in different colors as below.  ( Thanks to  <em>Jack Sleight</em> for the explanation of color and its description )
<ol>
<li><strong>Green</strong> : Loading the file from server.</li>
<li><strong>Dark Grey</strong> :  Request sent to server, file loaded from server</li>
<li><strong>Light Grey</strong>: Request sent to server, &#8220;Not Modified&#8221; received, file loaded from the cache.</li>
<li><strong>No bar for the file</strong>: No request sent to server, file loaded from cache</li>
</ol>
</li>
</ol>
<p>You should also note that <u>the list of files showing in the Net panel are sorted based on the order of how Firefox loaded those files.</u></p>
<p><strong>1.2. HTTP Headers</strong></p>
<p>The Net panel shows the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">HTTP headers</a> of every request/response messages so you can easily find out the interesting information like the parameters that are passed to server, the type of webserver, cookies and etc.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/header.jpg" alt="HTTP Header" /></p>
<p><strong> 1.3. Filter the requests by type</strong></p>
<p>If there are a lot of requests shown in Net panel, you can filter all of those requests based on the type of requests. For example, If you like to check the requests for image only then you can click the button called &#8220;Images&#8221; on toolbar to filter the requests for images.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/filter-by-type.jpg" /></p>
<p><strong>1.4. Full path of files and Image Preview</strong></p>
<p>If you move your cursor on the name of file (at the first column of Net panel), it will show you the full path of the file as a clickable link. If it is an image file then the actual image will be shown as a preview in Net panel. (Please check-out the pic below.)</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/request-details.jpg" /></p>
<p><strong> Summary about Net panel</strong></p>
<ul>
<li>It shows the headers for request/response messages for all kind of requests</li>
<li>It can be used for XMLHttpRequest monitoring ( The Console panel does this too.  You may check &#8220;Tracing XmlHttpRequest object&#8221; in <a href="http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii" title="Firebug Tutorial - Logging, Profiling and CommandLine (Part II)" target="_blank">this tutorial</a>. )</li>
<li>It sorts the files based on how Firefox loaded those files.</li>
<li>It shows the loading time, the size of each and every files.</li>
<li>It shows a particular file is loaded from server or cache.</li>
<li>Net panel is a packet sniffer. ( not like YSlow which is a DOM crawler.)</li>
</ul>
<p>Well. that&#8217;s all about Net panel. What do you think? Please leave a comment if you have any suggestion or comment.</p>
<p><u><strong>#2. CSS Panel</strong></u></p>
<p>The CSS panel  allows you to view/edit the stylesheet of your page. It is just very simple panel and doesn&#8217;t have so much feature in it.</p>
<p><strong>2.1. List of CSS files</strong></p>
<p>To see all CSS files of your page, just click the button (&#8220;michaelsync.net&#8221; for my case) beside &#8220;Edit&#8221; button. Then, the content menu will be shown and all CSS files will be listed on that menu. So, you can simply click any CSS file that you wanna view.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/list-of-files.jpg" /></p>
<p><strong>2.2 Normal Mode Vs Editable Mode of CSS Panel</strong></p>
<p>Like HTML tab, it has normal mode and editable mode.  If you click &#8220;Edit&#8221; button on the toolbar of CSS panel, it will become the editable mode.</p>
<p><u>Normal Mode</u></p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/css-normal-view.jpg" /></p>
<ul>
<li>Advantages
<ul>
<li>It shows the highlighted CSS syntax so looks nice.</li>
<li>It allows you to edit the attribute of CSS class.</li>
<li>It autocompletes as you type against the list of possible values for the property you are editing</li>
<li>It allows you to disable a particular style on the fly.</li>
</ul>
</li>
<li>Disadvantages
<ul>
<li>You can&#8217;t create new CSS class in this view.</li>
<li>It is difficult to remove one or more CSS class(es) from the file</li>
</ul>
</li>
</ul>
<p><u>Editable Mode</u></p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/editable-mode.jpg" /></p>
<ul>
<li>Advantages
<ul>
<li>        You got the full control of your CSS file so that you can edit/remove the CSS class as many as you want. You will feel like writing in notepad.</li>
</ul>
</li>
<li>Disadvantages
<ul>
<li>You will lost all syntaxhighlighting or autocomplete feature of CSS panel.</li>
</ul>
</li>
</ul>
<p><u><strong>#3. DOM panel</strong></u></p>
<p>It shows all default DOM properties, functions, constants, the user-defined properties and user-defined function.This panel is not very helpful (at least for me) except one thing. If you wanna find out how many function or properties included your scripts, you may probably want to use this panel to find out about that.</p>
<p>Let&#8217;s write one short script as below in plain HTML file.</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Untitled Page&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function Car(){
this.Gear = 5;
this.Start = function(){
console.log(&quot;Please put my car a lit bit!&quot;);
return false;
}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And then, save it as htm file. Open it in Firefox and then check the DOM tab. You will see the result as the picture below.  &#8220;Car()&#8221; is a function that you just wrote in JS, isn&#8217;t it?</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/10/dom.jpg" /></p>
<p>Okay. That&#8217;s all about DOM tab. This is the feature what DOM tab has so far&#8230;.</p>
<p>My tutorials for Firebug is ended here. I hope that you all do enjoy reading all of my tutorials. Actually, I&#8217;m not teaching you about Firebug. I&#8217;m just sharing the way I understand about Firebug and I believe that you found it useful. Any feedback are welcome as usual. Feel free to let me know if you have any suggestion or comment.</p>
<p>One more thing is that Yahoo is releasing the Firefox addon called <a href="http://developer.yahoo.com/yslow/" target="_blank">YSlow</a> integreated with Firebug. This tool is also a performance measuring tool like Net panel. YSlow used to determine the performance of webpage based on <a href="http://developer.yahoo.com/yslow/help/#guidelines">13 rules</a>. I&#8217;m currently learning about those rules and doing some experiments. I will post about this in details very soon.. Please keep on watching my blog&#8230;.</p>
<p>Thanks for reading. Have a nice day!!<br />
Michael Sync<br />
<em> Hey! don&#8217;t forget to give the feedback about my tutorials.. Here is the index.. Thanks..</em></p>
<p><strong>Firebug Tutorials </strong></p>
<ul>
<li><a href="http://michaelsync.net/2007/09/08/firebug-tutorial-overview-of-firebug/">Firebug Tutorial &#8211; Overview of Firebug</a></li>
<li>Console tab
<ul>
<li><a href="http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i/">Firebug Tutorial &#8211; Logging, Profiling and CommandLine (Part I)</a></li>
<li><a href="http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii/">Firebug Tutorial &#8211; Logging, Profiling and CommandLine (Part II)</a></li>
<li><a href="http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api">Firebug Tutorial &#8211; Using Commandline API in Firebug</a></li>
</ul>
</li>
<li>HTML tab
<ul>
<li><a href="http://michaelsync.net/2007/09/19/firebug-tutorial-html-tab-playing-with-html-dom">Firebug Tutorial &#8211; HTML tab : Playing with HTML DOM</a></li>
<li><a href="http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples">Firebug Tutorial &#8211; HTML Tab : Examples</a></li>
</ul>
</li>
<li>Script tab
<ul>
<li><a href="http://michaelsync.net/2007/09/30/firebug-tutorial-script-tab-javascript-debugging">Firebug Tutorial &#8211; Script Tab : Javascript Debugging</a></li>
</ul>
</li>
<li>Net, CSS and DOM
<ul>
<li><a href="http://michaelsync.net/2007/10/15/firebug-tutorial-section-4-net-css-and-dom-tabs">Firebug Tutorial &#8211; Section 4 : Net, CSS and DOM tabs</a></li>
</ul>
</li>
</ul>
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2007/10/15/firebug-tutorial-section-4-net-css-and-dom-tabs&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2007/10/15/firebug-tutorial-section-4-net-css-and-dom-tabs/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Firebug Tutorial &#8211; Script Tab : Javascript Debugging</title>
		<link>http://michaelsync.net/2007/09/30/firebug-tutorial-script-tab-javascript-debugging</link>
		<comments>http://michaelsync.net/2007/09/30/firebug-tutorial-script-tab-javascript-debugging#comments</comments>
		<pubDate>Sun, 30 Sep 2007 12:12:15 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Ajax debugging]]></category>
		<category><![CDATA[Firefox Addon]]></category>
		<category><![CDATA[Firefox Extension]]></category>
		<category><![CDATA[Javascript debugging]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2007/09/30/firebug-tutorial-script-tab-javascript-debugging</guid>
		<description><![CDATA[Firebug Tutorial Section 3: Script Tab : Javascript Debugging I&#8217;m going to show you how to debug the Javascript code with Firebug in this tutorial. If you are an Ajax developer, the tutorial will help you in many ways to...]]></description>
			<content:encoded><![CDATA[<h2>Firebug Tutorial</h2>
<h3>Section 3: Script Tab : Javascript Debugging</h3>
<p>I&#8217;m going to show you how to debug the Javascript code with Firebug in this tutorial. If you are an Ajax developer, the tutorial will help you in many ways to boost your production in your RIA (Rich Internet Application)  development.</p>
<p>The following topics will be covered in this tutorial.</p>
<ol>
<li>Overview of Script Tab</li>
<li>Debugging Javascript with Firebug</li>
<li>Javascript File Selector</li>
<li>Conditional breakpoint</li>
<li>Using Commandline API while debugging</li>
<li>debug(fn) and undebug(fu) &lt;CommandLine API&gt;</li>
</ol>
<p>Download : <a href="http://www.esnips.com/doc/f062a0cf-00c6-44ee-a3a7-1867457b69a9/Firebug---Samples" target="_blank">Sample File</a></p>
<p><strong>Note</strong> : <strong>Please refresh your web page if something goes wrong in Firebug console while you are debugging.</strong> As I&#8217;m using Firebug for my web project over 1 year, I know that this tool is very useful too. However, there are a few issues and limitations with this tool. So, please don&#8217;t mind about that. If you found any bug, you can report <a href="http://code.google.com/p/fbug/issues/entry">here</a>. OR, you can search the existing issue in <a href="http://code.google.com/p/fbug/issues/list">issue list</a>.</p>
<p><u><strong>#1. Overview of Script Tab</strong></u></p>
<p>The Script tab is the fourth tab of Firebug that allows you to debug the Javascript code on the browser. There are two subpanels in script panel. The panel on the left is the Javascript editor for debugging the javascript code. The subpanel on the right includes two sub panels called &#8220;Watch&#8221; and &#8220;breakpoint&#8221;. Please take a look the picture and description in below for more details.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/1-script-tab.jpg" alt="Firebug - Script Tab" /></p>
<ol>
<li><strong>JS Editor</strong> : This is the Javascript editor where you can debug the Javascript. There is one option called &#8220;Break on All Errors&#8221; in this editor. If you check this option, the script exection will be paused if the errors occurs in your script.</li>
<li><strong>JS File Selector</strong> : If you click on it, you will see the list of all Javascript files that are included in your page. (Please check &#8220;#3. Javascript File Selector&#8221; section for more details.)</li>
<li><strong>Line of Code &amp; breakpoint</strong> : This is a place where you can set the breakpoint for debugging.</li>
<li><strong>Watch Window</strong>: It displays the value of variables as a list in that window. If you have some experiences in using Microsoft Visual Studio, you already have some idea about how to use Watch window. There is only one difference between the Watch window from Firebug and the one from Visual Studio. In Visual Studio, the &#8220;Watch&#8221; window  displays the value of <strong>selected variables</strong>. But the &#8220;Watch&#8221; window of Firebug will display <strong>all values of variables</strong> within the current scope.</li>
<li><strong>list of breakpoints</strong> : The list of breakpoints that you set in Javascript Editor will be shown in that panel. You can also remove all breakpoints from that panel.</li>
</ol>
<p><u><strong>#2. Debugging Javascript with Firebug</strong></u></p>
<p>Debugging javascript is very straightforward process with Mozilla Firefox and Firebug. If you are Visual Studio developer then you won&#8217;t feel any differences while you are debugging the Javascript code with Firebug excepts the debugger runs as the part of browser. Let&#8217;s follow the steps to take a look how to debug the JS code.</p>
<p><strong>Steps to debug Javascript with Firebug</strong></p>
<ul>
<li>Copy the code below and paste them in notepad and save as a htm file. ( or If you already downloaded the sourcecode of this article, you can find the html file called   JS-Example1.htm in zip file. )</li>
</ul>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Javascript Debugging with Firebug&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function doSomething(){
var lbl = document.getElementById('messageLabel');
lbl.innerHTML = &quot;I just did something.&quot;;
}
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;div&gt;
&lt;div id=&quot;messageLabel&quot;&gt;&lt;/div&gt;
&lt;input type=&quot;button&quot; value=&quot;Click Me!&quot; onclick=&quot;doSomething();&quot; /&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Example 1.0</p>
<ul>
<li>Open your HTML file in Firefox browser.</li>
<li>Launch the Firebug console and go to &#8220;Script&#8221; tab.</li>
<li>Set the breakpoint on line 7 (as shown in pic below)
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/breakpoint-on-fb.jpg" alt="breakpoint-on-fb.jpg" /></li>
<li>Take a look at &#8220;Breakpoint&#8221; window at the right panel. (One line is added in &#8220;Breakpoints&#8221; windows as shown in pic.)
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/breakpoint-window.jpg" alt="breakpoint-window.jpg" /></li>
<li>Click &#8220;Click Me!&#8221; button on your page. (The Javascript execution will stop at the breakpoint that you set on line 7. )
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/break-on-line.jpg" alt="break-on-line.jpg" /></li>
<li>You can step thought the code by using one of those buttons (Continue, Step Over, Step Into and Step Out ) on the toolbar of Firebug.
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/step-out.jpg" alt="step-out.jpg" /><br />
(From left to right)</p>
<ul>
<li><strong>Continue (F8)</strong> : allow you to resume the script execution once it has been stopped via breakpoint</li>
<li><strong>Step Over (F10)</strong> : allow you to step over the function call.</li>
<li><strong>Step Into (F11)</strong> : allow you to step into the body of the another function.</li>
<li><strong>Step Out</strong> : allow you to resume the script execution and will stop at next breakpoint.</li>
</ul>
</li>
<li>So, click &#8220;Step Over&#8221; icon to go to the next line (line 8). (then, please take a look at &#8220;Watch&#8221; window. The values of variable called &#8220;lbl&#8221; will be displayed on &#8220;Watch&#8221; window. )
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/watch-window.jpg" alt="watch-window.jpg" /></li>
<li>then, Click &#8220;Step Over&#8221; icon to go to the next line. As there is no next line in our script, the execution will be stopped.</li>
</ul>
<p>Yeah. That&#8217;s all about simple Javascript debugging with Firebug. I will explain about more advanced features such as &#8220;using conditional breakpoint&#8221; and &#8220;using commandline API while debugging&#8221; in next example.</p>
<p><strong>Note about &#8220;Watch&#8221;window </strong>: Even though the value of the most variables are shown in &#8220;Watch&#8221; window, there might be some cases that you can&#8217;t find the variable you want in &#8220;Watch&#8221; window. In that case, the Commandline API are very helpful for you.</p>
<p><u><strong>#3. Javascript File Selector</strong></u></p>
<p>Using firebug console, you can easily find out how many script files are included in your page. (Please check-out the picture below. ) And also, you can change the script file that you wanna to debug.<br />
<img src="http://michaelsync.net/wp-content/uploads/2007/09/find-js-file-easily.jpg" /><br />
<strong><u><br />
#4. Conditional breakpoint</u></strong></p>
<p>The conditional breakpoint is very helpful when you don&#8217;t want to debug line-by-line. For example, there is one for-loop that loops 50 times in your code. If you set the normal breakpoint, the execution will be paused each time you enter in that loop. But if you are using conditional breakpoint, you can put the condition on your breakpoint so that the script execution won&#8217;t be paused every time you enter in that loop.</p>
<p>In order to show you how to use the conditional breakpoint, I will change the Javascript code as below from the previous example (e.g: 1.0). (<em>If you already downloaded the sourcecode of this tutorial, please take a look the html file called &#8220;JS-Example2.htm&#8221; in zip file.</em>)</p>
<pre class="brush: jscript; title: ; notranslate">
function Dwarf(name){
this.Name = name;
}

function DwarfFactory(){
var dwarfs = new Array();

this.AddDwarfs = function(){
dwarfs[0] = new Dwarf('Bashful');
dwarfs[1] = new Dwarf('Doc');
dwarfs[2] = new Dwarf('Dopey');
dwarfs[3] = new Dwarf('Grumpy');
dwarfs[4] = new Dwarf('Happy');
dwarfs[5] = new Dwarf('Sleepy');
dwarfs[6] = new Dwarf('Sneezy');
}

this.ShowDwarfs = function(){
for(var idx in dwarfs){
console.log(dwarfs[idx].Name);
}
}

this.ToString = function(){
var names = '';
for(var idx in dwarfs){
names += dwarfs[idx].Name + ' ';
}
return names;  //dwarfs.join(' ');
}
}

function doSomething(){
var objDwarfFactory = new DwarfFactory();
objDwarfFactory.AddDwarfs();
objDwarfFactory.ShowDwarfs();

var lbl = document.getElementById('messageLabel');
lbl.innerHTML = objDwarfFactory.ToString();
}
</pre>
<p>Example : 1.1</p>
<p>In our example, there is one for-loop in &#8220;ShowDwarfs()&#8221; function. We will set the conditional breatpoint in that loop. We wanna pause the script execution only when the name of dwarfs object is &#8220;Happy&#8221;. So, right-click on Javascript editor and put the condition &#8220;dwarfs[idx].Name == &#8216;Happy&#8217;&#8221; in the properties of breakpoint as shown in screenshot below. Then, press &#8220;Enter&#8221; key.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/conditional-breakpoint.jpg" alt="conditional-breakpoint.jpg" /></p>
<p>then, click the button on your webpage. The script execution will be paused when the condition that we put is true. We can also use the commandline API while debugging.</p>
<p><u><strong>#5. Using Commandline API while debugging</strong></u></p>
<p>If you have no idea about Firebug&#8217;s commandline API, I suggest you to read <a href="http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api/" title="Firebug Tutorial - Using Commandline API in Firebug" target="_blank">this tutorial</a> first.  Like we used to use &#8220;Immediate&#8221; window while we are debugging the code in Visual Studio, you can use Console panel with Commandline APIs while debugging Javascript with Firebug.</p>
<p>Let&#8217;s continue the previous example. The execution is paused when the condition is true. Then, you can go to Console panel and type any commandline API to find out more about current dwarf object. Let&#8217;s say we typed &#8220;console.dir(dwarfs[idx])&#8221; in one-line commandline. then, You will get the result &#8220;Name &#8220;Happy&#8221;" in console panel as pic below.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/consoledir-debug.gif" alt="consoledir-debug.gif" /></p>
<p><u><strong>#6. Using debug(fn) and undebug(fu) API</strong></u></p>
<p>As I said in my <a href="http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api/" title="Firebug Tutorial - Using Commandline API in Firebug" target="_blank">Commandline API article</a>,  I will explain about debug() and undebug() API here.</p>
<blockquote><p> #11. debug(fn) and undebug(fu)<br />
Adds or removes a breakpoint on the first line of a function.<br />
Note: I’m not going to cover about this API in this tutorial. Please read more about this in next section.</p></blockquote>
<p>Basically, debug(fn) and undebug(fn) APIs allows you to set/remove the breakpoint based on the function name from commandline or Javascript code instead of setting the breakpoint in script panel.</p>
<p>Example</p>
<ul>
<li>Open the &#8220;JS-Example2.htm&#8221; from zip file</li>
<li>Remove all breakpoints that you set earlier. (Script panel&gt;Breakpoint panel&gt;Options&gt;Remove all breakpoints)</li>
<li>Go to the Console panel.</li>
<li>Type &#8220;debug(doSomething)&#8221;</li>
<li>then, click &#8220;Click Me!&#8221; button. (Observe: The script execution will be paused at the first line of doSomething() function. )</li>
<li>If you want to remove the breakpoint that you set, type &#8220;undebug(doSomething)&#8221; in commandline.</li>
</ul>
<p>So, keep in mind that there are three ways to set the breakpoint in Firebug.</p>
<ol>
<li><strong>Static Breakpoint</strong> : It can be set based on line number. You need to set this kinda breakpoint by clicking the line of code bar in Script panel.</li>
<li><strong>Conditional breakpoint</strong> : It can be set based on the condition. You need to set this kinda breakpoint by clicking the line of code bar in Script panel.</li>
<li><strong>Dynamic breakpoint</strong> : It can be set based on the name of Javascript function. You can set this from commandline or Javascript code by using debug(fn) and undebug(fn).</li>
</ol>
<p>If you wanna try to debug Ajax application, there is one sample file called AjaxExample folder. So, feel free to try debugging this sample if you want.</p>
<p>Okay. that is all about debugging Javascript with Firebug. I hope you will help it useful. Sorry for taking so long to post this tutorial because there are a lot of problems in my country (Myanmar) so I have no mood to blog. :( Anyway, I have tried to cover as much as I can in this tutorial. Feel free to let me know if you have any comment or suggestion. Thanks for reading..
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2007/09/30/firebug-tutorial-script-tab-javascript-debugging&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2007/09/30/firebug-tutorial-script-tab-javascript-debugging/feed</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
		<item>
		<title>Firebug Tutorial &#8211; HTML Tab : Examples</title>
		<link>http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples</link>
		<comments>http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples#comments</comments>
		<pubDate>Sun, 23 Sep 2007 01:53:34 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples</guid>
		<description><![CDATA[Firebug Tutorial Section 2 : HTML Tab &#8211; Examples Example 1.1. How to inspect the HTML element or how to figure out the structure of the web design you like Note: I&#8217;m *NOT* encouraging people to copy the other people...]]></description>
			<content:encoded><![CDATA[<h2>Firebug Tutorial</h2>
<h3>Section 2 :  HTML Tab &#8211; Examples</h3>
<p><strong>Example 1.1. How to inspect the HTML element or how to figure out the structure of the web design you like</strong></p>
<p><em>Note:  I&#8217;m *NOT* encouraging people to copy the other people creative work. I&#8217;m just showing how to learn other people&#8217;s creation. Don&#8217;t get me wrong. :) If you are working in small software company, you probably might wear the multiple hats, which means you have to do coding (of course), user requirement, system design, UI design and so on. As you are not a designer, you may have some problems in designing things and not very sure about how to make things looks better.. so, you probably need to check other web designs and you need to adopt those designs to create your own one. For this fact, Firebug is the best tool for you. So, remember that it is not about copying thing. :)</em></p>
<p><strong><em>Scenario</em> ~   Let&#8217;s say you think that the menu bar of <a href="http://www.apple.com/ipodtouch/guidedtour/">iPod Touch webpage of apple</a> is impressive. You wanna know how the toolbar is created.</strong></p>
<p style="text-align:center;"><img src="http://michaelsync.net/wp-content/uploads/2007/09/ipodtouch-small.jpg" /></p>
<ul>
<li>Open <a href="http://www.apple.com/ipodtouch/guidedtour/">IPod Touch webpage</a> in Mozilla Firefox.</li>
<li>Click &#8220;Inspect&#8221; button from the toolbar of Firebug console.</li>
<li>Move your cursor on the menu of the website by using mouse.</li>
<li>Click the element (menuitem) that you wanna inspect ( Note: I suggested you to select the first item of menu because it is easy to find out about the main HTML element. (Let&#8217;s say we selected &#8220;Apple icon&#8221; ))</li>
</ul>
<p style="text-align:center;"><img src="http://michaelsync.net/wp-content/uploads/2007/09/inspect-the-apple-toolbar.jpg" /></p>
<ul>
<li>(In our example, we selected the first menuitem of menu in webpage so that the related HTML element &lt;A&gt; tag is highlighted in &#8220;View Source&#8221; HTML panel. Don&#8217;t forget to take a look the &#8220;Style&#8221; panel at the right-side. The CSS rule that are styling to that &lt;A&gt; tag are shown in that panel. Then, You can easily figure out that the DIV called &#8220;global header&#8221; is the main for this menu.  )</li>
<li>Select the DIV &#8220;globalheader&#8221;</li>
<li>Right-click on the element and select &#8220;Copy HTML &#8221; from content menu.</li>
<li>Create new HTML file and pasted it within &lt;body&gt; tag.</li>
<li>After that, Check the CSS rule in Style panel. (In our case, &#8220;#globalheader&#8221; and &#8220;<span class="cssSelector">html, body, div, ul, ol, li, dl, dt, dd, h1, h2, h3, h4, h5, h6, pre, form, p, blockquote, fieldset, input</span>&#8221; are the CSS rule that are styling to that A link. The blue link &#8220;nav.css&#8221; shows the source CSS file. Plus,  the inherited CSS rules from ipod.css and base.css are also shown in &#8220;Style&#8221; panel)</li>
<li>So, copy those CSS and pasted them in your html file.You can repeat this step to find the CSS rule for each HTML element. But it took some times to grasp all CSS rules since you have to go one HTML element after another.. So, the best way would be copying all CSS rules from the source.</li>
<li>In order to copy the whole CSS rules from the source file, click the blue link &#8220;nav.css&#8221; then it will take you to &#8220;Style&#8221; panel (not the one from HTML panel) as the picture below.
<p style="text-align:center;"><img src="http://michaelsync.net/wp-content/uploads/2007/09/style-view.gif" /></p>
<p>The CSS rule that you selected in the &#8220;Style&#8221; subpanel of  HTML panel will be highlighted.</li>
<li>Click &#8220;Edit&#8221; button on the toolbar of &#8220;Style&#8221; panel</li>
<li>Select all CSS rules and Copy</li>
<li>then, paste them in your HTML file.</li>
<li>Copy the inherited CSS rule for body tag from base.css and paste them in your HTML file.</li>
<li>Check the images path and copy those required images also.</li>
<li>Finally, you got the great menubar that you are looking for.</li>
</ul>
<p>Let me know if you are not very clear about those steps.. I have uploaded the sample <a href="http://www.esnips.com/doc/b85234e4-49d9-4496-94a5-a770b19fd8ac/ipodtouch/">here</a>. [<a href="http://www.esnips.com/doc/b85234e4-49d9-4496-94a5-a770b19fd8ac/ipodtouch/">link</a>] You can download it if you wanna take a look the sample.</p>
<p><strong>Screenshot</strong></p>
<p style="text-align:center;"><img src="http://michaelsync.net/wp-content/uploads/2007/09/apple-menu.jpg" /></p>
<p align="center">*****</p>
<p><strong> Example 1.2. &#8220;Scroll into View&#8221; and &#8220;Searching&#8221; in HTML tab.</strong></p>
<p>Searching feature of HTML is useful if you wanna find something in HTML Source. (The default search of Mozilla Firefox is for searching the text. not for searching the HTML source.) Searching feature is more helpful if you use &#8220;Scroll Into View&#8221; after search. If you found something you want in HTML tab then you can click &#8220;Scroll Into View&#8221; to scroll that thing into view.</p>
<p><strong><em>Scenario</em>  :  How to find your photo in <a href="http://www.2kbloggers.com/photo-montage">2kbloggers Photo Montage Page</a>? </strong></p>
<p style="text-align:center;"><img src="http://michaelsync.net/wp-content/uploads/2007/09/2kblogger.jpg" /></p>
<p>Let&#8217;s say you are one of members of 2kbloggers team. so, your photo will be included in <a href="http://www.2kbloggers.com/photo-montage">Photo Montage page</a> of 2kbloggers website. As there are too many photos in that page, it is not so easy to find yourself among those photos. The Firefox default search is useless for that case. Fortunately, The search feature of HTML panel of Firebug will help you to find your photo in very easy way.</p>
<p>Steps ~</p>
<ul>
<li> Launch Firebug console in that page.</li>
<li>Go to HTML Console</li>
<li>Type your blog link (eg: http://michaelsync.net) in Search textbox. (note: please type a lit bit slow and wait)<img src="http://michaelsync.net/wp-content/uploads/2007/09/search.jpg" /></li>
<li>After you finished typing, the Anchor element which is belong to your link will be highlighted in &#8220;View Source&#8221; panel.</li>
<li>Move your cursor on the src of image link. Firebug will show the photo that you are looking for.<img src="http://michaelsync.net/wp-content/uploads/2007/09/link.jpg" /></li>
<li>Right-click on that element and click &#8220;Scroll into View&#8221;</li>
<li>Then, check the photo at the first line under toolbar of Mozilla Firefox. Your photo will be there at the first line..</li>
</ul>
<p>That&#8217;s all. Don&#8217;t hesitate to contact me if you have any problem for those tutorials.</p>
<p>Thanks for reading.
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Firebug Tutorial : HTML tab &#8211; Playing with HTML DOM</title>
		<link>http://michaelsync.net/2007/09/19/firebug-tutorial-html-tab-playing-with-html-dom</link>
		<comments>http://michaelsync.net/2007/09/19/firebug-tutorial-html-tab-playing-with-html-dom#comments</comments>
		<pubDate>Wed, 19 Sep 2007 17:10:00 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2007/09/19/firebug-tutorial-html-tab-playing-with-html-dom</guid>
		<description><![CDATA[Firebug Tutorial Section 2 : HTML Tab &#8211; All about HTML tab Introduction The HTML tab is the second tab of Firebug console that allows you to play with HTML DOM in your browser. There are &#8220;View Source&#8221; window in...]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.getfirebug.com/?link=1" title="Firebug is a free web development tool for Firefox"><img src="http://www.getfirebug.com/images/firebug-web-development.png" alt="Firebug - Web Development Evolved" /></a></p>
<h2>Firebug Tutorial</h2>
<h3>Section 2 :  HTML Tab &#8211; All about HTML tab</h3>
<p><strong>Introduction</strong></p>
<p>The HTML tab is the second tab of Firebug console that allows you to play with HTML DOM in your browser. There are &#8220;View Source&#8221; window in the left side of the HTML panel and 3 sub panels called &#8220;Style&#8221;, &#8220;Layout&#8221; and &#8220;DOM&#8221; in right side. The HTML tab will help you to find out how a particular web page is structured.  It is allowed to edit the HTML element or CSS rule dynamically on the live view.</p>
<p>The following are what HTML tab can do for you.</p>
<p><strong>Features</strong> ~</p>
<ul>
<li>Inspect HTML element</li>
<li>Explore the style of a particular HTML element</li>
<li>Explore the HTML DOM of the whole document</li>
<li>Edit the existing HTML element and CSS</li>
<li>Search the internal HTML element instead of Text on the page.</li>
</ul>
<p><strong><u>The &#8220;View Source&#8221; panel</u> </strong></p>
<p>The &#8220;View Source&#8221; window located at the right side of HTML panel.  It has more advanced features than what the default &#8220;View Source&#8221; of Firefox browser has. It shows the HTML DOM in hierarchical structure or treeview with highlight color. (Please check the screenshot below.). It allows you to expand/collapse the HTML dom so that it is very easy for you to figure out the whole structure of the webpage.  Another advantage of  that HTML &#8220;view source&#8221; is that it allows you to edit/delete the HTML elements or attributes on the fly and the changes will immediately affect to the webpage that you are watching.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/html-view.jpg" alt="html-view.jpg" /></p>
<p><u><strong>Options of &#8220;View Source&#8221; panel</strong></u></p>
<p>There are six options as below in &#8220;View Source&#8221; panel.</p>
<ol>
<li><strong>Show Full Text</strong> : If the text within a element (i.e: &lt;P&gt; tag ) are too long then Firebug will truncate this text and will append &#8220;&#8230;&#8221; after the string.</li>
<li><strong>Show White Space</strong> : It shows the white space between each HTML element. I don&#8217;t think that option is useful.</li>
<li><strong>Show Comments</strong> : Check this option if you want to show the comment in &#8220;View Source&#8221; panel. otherwise, unchecked.</li>
<li><strong>Highlight Changes </strong>: It shows in highlight color if you make some changes in HTML view.</li>
<li><strong>Expand Changes</strong> : It will expand the HTML element that has changes. ( But it seems doesn&#8217;t work properly. it always expand the node even &#8220;Expand Changes&#8221;  option is not selected .)</li>
<li><strong>Scroll Changes Into View</strong> : The scroll bar of &#8220;View Source&#8221; panel will move to the place where something has changed.</li>
</ol>
<p>Note: If you are not very clear about option 4, 5 and 6,  go to <a href="http://www.esnips.com/doc/64716a4d-e62b-4450-97f7-f64174cd8553/HTMLPage1">this page</a>. There are two buttons on that page. Open the Firebug console by pressing F12 and click &#8220;HTML&#8221; tab. Check some or all of those options (4,5 and 6) in Option menu of HTML tab. Click one of those buttons on that page and find out what is happening in HTML panel.. For example, you select &#8220;Scroll Changes Into View&#8221; option and then,  you click the button to append new row to the HTML table. Then, the HTML view will scroll to the position where the changes occur.</p>
<p><u><strong>Left Menu of &#8220;View Source&#8221; panel</strong></u></p>
<p>You will see the following menus if you right-click on the HTML element in &#8220;View Source&#8221;  Panel.</p>
<ul>
<li><strong>Copy HTML</strong> : Copy the whole HTML element that you selected.</li>
<li><strong>Copy innerHTML</strong> :  Copy the innerHTML of HTML element that you selected.</li>
<li><strong>Copy XPath</strong> : Copy the xpath of HTML. (i.e: /html/head/title)</li>
<li><strong>Scroll Into View</strong> : Move the HTML element into View. (See the example 1.2 of <a href="http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples/">next post</a> for details)</li>
<li><strong>New Attribute</strong> : Create new attribute in exisiting HTML element</li>
<li><strong>Edit HTML</strong> : It allows you to edit the HTML on the fly.</li>
<li><strong>Delete Element</strong> : Delete the existing HTML element on your page.</li>
<li><strong>Inspect in DOM tab</strong> : Get the properties of the selected HTML element in DOM tab.</li>
</ul>
<p>Now, I think that you have some ideas about &#8220;View Source&#8221; panel. So, let&#8217;s take a look how to inspect the HTML element.</p>
<p><strong><u>Inspecting HTML element</u></strong></p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/inspect-button.jpg" alt="inspect-button.jpg" /></p>
<p>The button called &#8220;Inspect&#8221; at the right side of HTML toolbar as the picture above allows you to inspect the HTML element of the web page. All you need to do is that just click that button and move your mouse around the webpage. The HTML element under your cursor will be highlighted and the related elements will be selected in &#8220;View Source&#8221; panel of HTML tab. ( Please check the image below if you want to know how it looks like. )</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/inspect-html-demo.jpg" alt="inspect-html-demo.jpg" /></p>
<p>There are two reasons why this feature is useful for web developers or webdesigners.</p>
<ol>
<li>It is useful when we are figuring out why something in our page doesn&#8217;t look okay.</li>
<li>It is also useful when we are learning other people&#8217;s web design and how people created those designs. (I say &#8220;learning&#8221; but not copying other people&#8217;s work. Sometimes, it is not good enough to keep on creating our own stuffs without caring about how the world is moving. As there are a lot of websites that have gorgeous design on internet, we should take a look a lit bit how those designs are structured. )</li>
</ol>
<p><u><strong>Editing the HTML element and attribute</strong></u></p>
<ol>
<li><strong>Editing the exisiting attribute of HTML element</strong><br />
Just click on the attribute. It will show the textbox on the attribute as the picture below. You can just key-in and press &#8220;Enter&#8221; when you have done.<img src="http://michaelsync.net/wp-content/uploads/2007/09/edit-attribute.jpg" alt="edit-attribute.jpg" /></li>
<li><strong>Creating new attribute in the existing HTML element</strong><br />
Right-click on the exisiting HTML element and select &#8220;New Attribute&#8221; on content menu. The placeholder for new attribute will be shown as the picture below.<img src="http://michaelsync.net/wp-content/uploads/2007/09/new-atttribute.jpg" alt="new-atttribute.jpg" /></li>
<li><strong>Creating/Editing the HTML element</strong><br />
If you want to create or edit the HTML element, righ-click on the HTML element and select &#8220;Edit HTML&#8221; on content menu or click &#8220;Edit&#8221; button on the toolbar of HTML tab.  The &#8220;View Source&#8221; panel will change to something like notepad. Then, you can edit the existing HTML element or  add new HTML element.  If you finish editing, click Edit&#8221; button then it will change to normal &#8220;View Source&#8221; panel and the changes will affect to the webpage.<img src="http://michaelsync.net/wp-content/uploads/2007/09/edit-html.jpg" alt="edit-html.jpg" /></li>
<li><strong>Deleting the HTML element.</strong><br />
This one is very simple. You need to right-click on the note that you wanna delete. and chose &#8220;Delete Element&#8221; on content menu.</li>
</ol>
<p><u><strong>The &#8220;Style&#8221;, &#8220;Layout&#8221; and &#8220;DOM&#8221; subpanels</strong></u></p>
<p><strong>Style panel</strong></p>
<p>Those sub panels work very closely with &#8220;View Source&#8221; panel. If you select one of HTML element in &#8220;View Source&#8221; panel, the CSS rules that are styling to that element will be shown in the &#8220;Style&#8221; subpanel and the properties of that element will be shown in &#8220;DOM&#8221;. It is so easy for you to find out which CSS rules are styling to which element.</p>
<p>Take a look at this picture. We selected the div called &#8220;page&#8221; in &#8220;View Source&#8221; panel. The CSS rule (i.e: #page in this case) that is styling this DIV element will be shown in &#8220;Style&#8221; panel.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/explore-the-stylesheet-of-element.jpg" alt="explore-the-stylesheet-of-element.jpg" /></p>
<p><strong>Editing the CSS attribute</strong></p>
<p>You can also edit the CSS style (i.e: margin, width  or etc) in &#8220;Style&#8221; panel.  When you click on the attribute, it will show one textbox that you can type anything you want. If you forget the stylesheet attribute name, you can press &#8220;Up&#8221; or &#8220;Down&#8221; key to get the available stylesheet. It is  like IntelliSense in Visual Studio.</p>
<p><strong>Computed Style</strong></p>
<p>If you like to see the CSS rule in computed style, you can change the look by checking &#8220;Show Computed Style&#8221; in the option of Style panel. I don&#8217;t think that option is very nice. I more prefer to use the default one.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/show-computed-style.jpg" alt="show-computed-style.jpg" />s</p>
<p><strong> Layout Panel</strong></p>
<p>If you click on the &#8220;Layout&#8221; tab, you will get the offset, margin, border and padding of the HTML element that you have selected in &#8220;View Source&#8221; panel. You can display the vertical ruler and horizontal ruler on your page if you check &#8220;Show Rulers and Guides&#8221; in the option of &#8220;Layout&#8221; panel. And you can also edit the value of offset, margin, border and padding of that element.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/layout.jpg" /></p>
<p><strong>DOM panel</strong></p>
<p>DOM panel shows all DOM properties of the HTML element that you have selected in &#8220;View Source&#8221; panel.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/dom-tab.jpg" alt="dom-tab.jpg" /></p>
<p><strong>Conclusion</strong></p>
<p>That is all about HTML tab. I covered everything about HTML tab in one post. So, it might be a lit bit confused for you.  Let me show you which one is more important and which one is less.</p>
<ol>
<li>Inspect HTML, &#8220;View Source&#8221; panel and &#8220;Style&#8221; panel [ <em>This is very important so you must know about this</em> ]</li>
<li>Edit the HTML element and CSS [ <em>this is good to know.</em>  ]</li>
<li>&#8220;Layout&#8221; panel and &#8220;DOM&#8221; panel [ <em>good to know but doesn't matter if you don't know. </em>]</li>
</ol>
<p>Okay. I will stop this tutorial here. <strike>I will post about some examples related to HTML tab in next post..</strike></p>
<p><strong>Updated:</strong>  I have posted two examples related to HTML tab in this post. &lt;link: <a href="http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples/">http://michaelsync.net/2007/09/23/firebug-tutorial-html-tab-examples/</a>&gt;. Hope you will find it useful..</p>
<p>Feel free to let me know if you have any suggestion or comment. Thanks..
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2007/09/19/firebug-tutorial-html-tab-playing-with-html-dom&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2007/09/19/firebug-tutorial-html-tab-playing-with-html-dom/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Firebug Tutorial &#8211; Using Commandline API in Firebug</title>
		<link>http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api</link>
		<comments>http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api#comments</comments>
		<pubDate>Sat, 15 Sep 2007 07:37:45 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api</guid>
		<description><![CDATA[Firebug Tutorial Section 1: Console Tab : Using Commandline API in Firebug Introduction Commandline is one of the most useful features of Firebug. If you have some experiences in using Microsoft Visual Studio, you may know the usefulness of &#8220;Immediate...]]></description>
			<content:encoded><![CDATA[<h2>Firebug Tutorial</h2>
<h3>Section 1: Console Tab : Using Commandline API in Firebug</h3>
<p><strong>Introduction</strong></p>
<p>Commandline is one of the most useful features of Firebug. If you have some experiences in using Microsoft Visual Studio, you may know the usefulness of &#8220;Immediate window&#8221;  and &#8220;Watch window&#8221; of VS while you are debugging.</p>
<p>Firebug&#8217;s commandline is like the &#8220;immediate window&#8221; from Visual Studio. You can inspect the value of a particular object at anytime. One better thing with firebug&#8217;s commandline is that it can be used at design-time also. ( Note: &#8220;Immediate&#8221; window from VS can be used at debugging-time only). And, another advantage is that you can write the Javascript Code in commandline and execute those codes on the fly.</p>
<p>The list of Commandline APIs for Firebug are available in the official website of Firebug. [ link: <a href="http://getfirebug.com/commandline.html" title="Firebug - CommandLine API" target="_blank">http://getfirebug.com/commandline.html</a>]. What I&#8217;m going here is that I&#8217;m gonna write about all Commandline APIs with examples in this tutorial.  I hope that you will find it useful.</p>
<p><strong>Types of CommandLine</strong></p>
<p>There are two types of Commandline in Console panel.</p>
<ul>
<li>One-line Commandline</li>
<li>Multi-lines Commandline</li>
</ul>
<p><strong>One-line Commandline</strong></p>
<p>This one is the default one for Console panel of Firebug. It allows you to write one line at a time. The advantage of one-line commandline is that it supports <u>autocomplete feature</u>.</p>
<blockquote><p><strong>What is Autocomplete?</strong>(Ref: <a href="http://getfirebug.com/cl.html">http://getfirebug.com/cl.html</a>)</p>
<p>Using the tab key you can autocomplete the name of variables and object properties. Keep hitting it to cycle through the complete set of possibilities, and use shift-tab to go backwards.</p>
<p>Autocomplete works at many levels. You can start hitting tab before you type anything to cycle through global variables. You can hit tab after typing &#8220;document.b&#8221; to cycle thorugh all properties that start with &#8220;b&#8221;. You can even hit tab after a complex expression like &#8220;document.getElementsByTagName(&#8216;a&#8217;)[0].&#8221; to see all properties of the first link in the document.</p></blockquote>
<p>Plus, You can also use &#8220;Up&#8221; or &#8220;Down&#8221; keys to get the command that you typed earlier.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/commandline.jpg" alt="commandline.jpg" /></p>
<p><strong>Multi-lines Commandline </strong></p>
<p>The multi-lines commandline is the enhancement version of one-line commandline. It allows you to type the Javascript code more than one time.  And you can execute the code on the fly.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/commandline-larger.jpg" alt="commandline-larger.jpg" /></p>
<p>Both one-line commandline and multi-lines commandline have their own advantages. So, you can use either one based on what you wanna do with Firebug. For me, I used to use one-line commandline at the most of the time.</p>
<p><strong>CommandLine API with example</strong></p>
<p>Before start reading the tutorials, note that all of those APIs can be used both design time or run-time. However, those are more useful while you are in debugging mode. I&#8217;m telling you this because you may wonder why you need those APIs. :)</p>
<p><strong>Download</strong> ~ <a href="http://www.esnips.com/doc/492ea973-7a24-4c2c-a64f-cd1eda2a1976/CommandLine/?widget=documentIcon">Demo Zip File</a></p>
<p><strong>List of APIs</strong></p>
<ol>
<li> $(id)</li>
<li>$$(selector)</li>
<li>$x(xpath)</li>
<li>dir(object)</li>
<li>dirxml(node)</li>
<li>cd(window)</li>
<li>clear()</li>
<li>inspect(object[, tabName])</li>
<li>keys(object)</li>
<li>values(object)</li>
<li>debug(fn) &amp; undebug(fn)</li>
<li>monitor(fn) &amp; unmonitor(fn)</li>
<li>monitorEvents(object[, types]) &amp; unmonitorEvents(object[, types])</li>
<li>profile([title]) &amp; profileEnd()</li>
</ol>
<p><u><strong>#1. $(<em>id</em>)</strong></u></p>
<p>Returns a single element with the given id.</p>
<p>This is the shortcode for document.getElementById(&#8221;) in Javascript.</p>
<p>Example ( 1.0 )~</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;body&gt;
Name : &lt;input id=&quot;nameTextBox&quot; class=&quot;normalText&quot; type=&quot;text&quot; /&gt;
&lt;/body&gt;
</pre>
<p>How-to ~</p>
<ul>
<li>Paste the code above in blank HTML file and open it in Firebug.</li>
<li>Open the Firebug console and click &#8220;Console&#8221; tab.</li>
<li>Type $(&#8216;nameTextBox&#8217;) in CommandLine and Press Enter Key</li>
</ul>
<p>Output ~</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/sample.jpg" alt="sample.jpg" /></p>
<p>It seems very simple (and looks like not very useful) but I would say that it is useful while you are debugging the code or writing the script in multi-lines commandline.</p>
<p>Let&#8217;s see how to use multi-lines commandline, how to execute the Javascript on the fly.</p>
<ul>
<li>Click &#8220;Options &gt; Larger Command Line&#8221;</li>
<li>Copy the code below and paste them in multi-lines commandline (larger commandline).</li>
<li>Click &#8220;Run&#8221;</li>
</ul>
<pre class="brush: jscript; title: ; notranslate">
var txt = $('nameTextBox');

txt.value = 'Michael Sync';
txt.textAlign = 'center';
txt.style.color = 'blue';
txt.style.borderStyle = 'double';
txt.style.borderColor = 'pink';
</pre>
<p>Output ~</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/multiline-cmdline.jpg" alt="multiline-cmdline.jpg" /></p>
<p><u><strong>#2.  $$(selector)</strong></u></p>
<p>Returns an array of elements that match the given CSS selector.</p>
<p><em>Note: Check the link <a href="http://www.w3.org/TR/css3-selectors/" title="CSS Selector">here</a> if you don&#8217;t know what CSS selector is.</em></p>
<p>Example ( 1.1 )~</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Firebug&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
div{
background-color:Black;color:White; border: solid 1px grey;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id='div1'&gt;This is DIV1.&lt;/div&gt;
&lt;br /&gt;
&lt;div id='div2'&gt;Here is one more.&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><em>Note: I&#8217;m using &#8220;Type CSS selector&#8221; in this sample.</em></p>
<p>How-to ~</p>
<ul>
<li>Type $$(&#8216;div&#8217;) in CommandLine and Press Enter Key (You will get both div objects (div1 and div2) as an array. )</li>
</ul>
<p><u><strong>#3. $x(xpath)</strong></u></p>
<p>Returns an array of elements that match the given XPath expression.</p>
<p><em>Note: If you have no idea about XPath, you may check the XPath tutorial <a href="http://www.w3schools.com/xpath/" title="Free XPath Tutorial" target="_blank">here [^]</a>. </em></p>
<p>Example ( 1.2 )~</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;CommandLine - $&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id='container' style=&quot;width:800px&quot;&gt;
&lt;div id='leftsidebar' style=&quot;width:100px; background-color:Gray;min-height:400px;float:left;&quot;&gt; &lt;/div&gt;
&lt;div id='content' style=&quot;width:600px;min-height:400px; background-color:ThreeDShadow;float:left;&quot;&gt;
&lt;div id='content-header' style=&quot;padding:2px;font-family:Calibri,Trebuchet MS;&quot;&gt;
&lt;h2&gt;All about Firebug&lt;/h2&gt;
&lt;/div&gt;
&lt;div id='content-body' style=&quot;padding:2px;font-family:Calibri,Trebuchet MS;&quot;&gt;
&lt;p&gt;Firebug is the most popular tool in web revolution.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id='rightsidebar' style=&quot;width:100px; background-color:Gray;height:400px;float:right;&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>We will test this API in multi-lines commandline.</p>
<p>Paste the code below in multi-lines commandline.</p>
<pre class="brush: jscript; title: ; notranslate">
var obj = $x('html/body/div/div');
console.log(obj[0].id);
console.log(obj[1].id);
console.log(obj[2].id);
</pre>
<p>Output ~</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/x-result.jpg" alt="x-result.jpg" /></p>
<p><u><strong>#4. dir(object)</strong></u></p>
<p>Prints an interactive listing of all properties of the object. This looks identical to the view that you would see in the DOM tab.</p>
<p><em>It is like console.dir() that I already mentioned in <a href="http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i/">Part I.</a></em> So, I think you already have some idea about what console.dir is and how to use. I&#8217;m not going to write the new HTML code for this example. Instead, I will use the previous example (eg 1.2) and I will change the Javascript code that I wrote in multi-lines commandline.</p>
<pre class="brush: jscript; title: ; notranslate">
var obj = $x('html/body/div/div');
&lt;strong&gt;dir(obj);&lt;/strong&gt;
</pre>
<p>The result will be like the pic below. You will get all properties and methods of those three DIV objects (leftsidebar, content, rightsidebar).</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/dir.jpg" alt="dir.jpg" /></p>
<p><u><strong>#5. dirxml(note)</strong></u></p>
<p>Prints the XML source tree of an HTML or XML element. This looks identical to the view that you would see in the HTML tab. You can click on any node to inspect it in the HTML tab.</p>
<p>I already showed you how to use console.dirxml() in <a href="http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i/">this tutorial</a>. Only one thing is different. You can type dirxml() (eg: dirxml(&#8216;container&#8217;)  with the example 1.2.) in commandline instead of writing in HTML file.</p>
<p><strong><u>#6. cd(window)</u> </strong></p>
<p>By default, command line expressions are relative to the top-level window of the page. cd() allows you to use the window of a frame in the page instead.</p>
<p>Note: This API seems doesn&#8217;t work properly. I will inform to Firebug team and will let you know the result.</p>
<p><u><strong>#7. clear()</strong></u></p>
<p>Clears the console. If you wanna clear the console, just type this &#8220;clear()&#8221;  in commandline and press &#8220;Enter&#8221; key. You can also use &#8220;console.clear()&#8221; in Javascript Code.</p>
<p><strong><u>#8. inspect(object[,tabName])</u> </strong></p>
<p>Inspects an object in the most suitable tab, or the tab identified by the optional argument <code>tabName</code>.</p>
<p>The available tab names are &#8220;html&#8221;, &#8220;css&#8221;, &#8220;script&#8221;, and &#8220;dom&#8221;.</p>
<p>How-to ~</p>
<ul>
<li>Open &#8220;example 1.2&#8243; in firefox.</li>
<li>Type inspect($(&#8216;content-header&#8217;),&#8217;html&#8217;)  in one-line commandline.</li>
<li>The  HTML tab  will be opened and  the DIV called &#8220;content-header&#8221; will be selected. (check the pic below)</li>
</ul>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/inspect-html.jpg" alt="inspect-html.jpg" /></p>
<p><strong><u>#9. keys(object)</u> </strong></p>
<p>Returns an array containing the names of all properties of the object. The object can be either Javascript object ( eg: var objCar = new Car() ) or HTML element (eg: document.getElementById(&#8216;table1&#8242;)).</p>
<p>Example 1.4 ~</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Keys and Values&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table id=&quot;tbl1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot;&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
function Car(){
this.Model = &quot;Old Model&quot;;
this.getManufactor = new function(){
return &quot;Toyota&quot;;
}
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>How-to ~</p>
<ul>
<li>Open &#8220;Example 1.4&#8243;  in firefox</li>
<li>Open the &#8220;console&#8221; tab.</li>
<li>Go to multi-lines commandline by clicking &#8220;Larger Command Line&#8221; in Option menu</li>
<li>Write the following code in commandline
<pre class="brush: jscript; title: ; notranslate">
var o = new Car();
keys(o);
</pre>
</li>
<li>You will get the names of all properties of this JS class called &#8220;Car&#8221;.</li>
</ul>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/keys.jpg" alt="keys.jpg" /></p>
<p>Note: If you wanna practice this API, try to get the names of all properties of the HTML table called &#8216;tbl1&#8242; by using this API. Let me know what result you get. :)</p>
<p><u><strong>#10. values(object)</strong></u></p>
<p>Returns an array containing the values of all properties of the object.</p>
<p>Example : Ref: to example 1.4.</p>
<p>How-to ~</p>
<ul>
<li>Open &#8220;Example 1.4&#8243;  in firefox</li>
<li>Open the &#8220;console&#8221; tab.</li>
<li>Go to multi-lines commandline by clicking &#8220;Larger Command Line&#8221; in Option menu</li>
<li>Write the following code in commandline
<pre class="brush: jscript; title: ; notranslate">
var o = new Car();
&lt;strong&gt;values(o);&lt;/strong&gt;
</pre>
</li>
<li>You will get the values of all properties of this JS class called &#8220;Car&#8221;.</li>
</ul>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/values.jpg" alt="values.jpg" /></p>
<p>Note: As the getManufactor of Car() class is a function, it shows &#8220;Object&#8221; (green link) instead of the value &#8220;Toyota&#8221;.</p>
<p><u><strong>#11. debug(fn) and undebug(fu)</strong></u></p>
<p>Adds or removes a breakpoint on the first line of a function.</p>
<p>Note: I&#8217;m not going to cover about this API in this tutorial. Please read more about this in next section.</p>
<p><u><strong>#12. monitor(functionName)  and unmonitor(functionName)</strong></u></p>
<p>Turns on/off logging for all calls to a function.</p>
<p>Normally, If we want to know whether a particular function is invoked or not, we used to put &#8220;alert()&#8221;or &#8220;console.log()&#8221; in that function. It&#8217;s too much work if we are working on large script files because we need to find that function in all script files and put &#8220;alert()&#8221; or &#8220;console.log&#8221; in that function. and save that file again and run on the browser. With firebug, you don&#8217;t need to do those things. You only need to know the function and you can trace how many time that function is invoked. You will get the notification in console when that function that you monitored is invoked. Plus, it will give you a link that is pointing the function in script.</p>
<p>Example 1.5 ~</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Monitor and Profiler&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function func1(){
//doSomething
}
function func2(){
//doSomething
}
function func3(){
//doSomething
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input id=&quot;btn1&quot; type=&quot;button&quot; value=&quot;Invoke func1()&quot; onclick=&quot;func1();&quot;/&gt;
&lt;input id=&quot;btn2&quot; type=&quot;button&quot; value=&quot;Invoke func2()&quot; onclick=&quot;func2();&quot;/&gt;
&lt;input id=&quot;btn3&quot; type=&quot;button&quot; value=&quot;Invoke func3()&quot; onclick=&quot;func3();&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>How-to ~</p>
<ul>
<li>type &#8220;monitor(func1) &#8221; in one-line commandline (wait a few seconds until &#8220;&gt;&gt;&gt; monitor(func)&#8221; is shown in commandline)</li>
<li>then, you can click any of those buttons to invoke the function that you like.</li>
<li>Since we are monitoring the function called &#8220;func1()&#8221;, we get the link ( check-out the picture below) as a notification whenever you click the button &#8220;Invoke func1()&#8221;. But you won&#8217;t get anything when you click other buttons. This is how the monitor API works in Firebug. You will get the notification when the functions that you are monitoring are invoked.</li>
<li>Type &#8220;unmonitor(func1)&#8221; to remove monitoring the func1();</li>
</ul>
<p>Output ~</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/monitor.jpg" alt="monitor.jpg" /></p>
<p><u><strong>#13. monitorEvents(object[, types]) and unmonitorEvents(object[, types])</strong></u></p>
<p>Turns on/off logging for all events dispatched to an object.</p>
<p>The optional argument &#8220;types&#8221; may specify a specific family of events to log. The most commonly used values for types are &#8220;mouse&#8221; and &#8220;key&#8221;.</p>
<p>The full list of available types includes &#8220;composition&#8221;, &#8220;contextmenu&#8221;, &#8220;drag&#8221;, &#8220;focus&#8221;, &#8220;form&#8221;, &#8220;key&#8221;, &#8220;load&#8221;, &#8220;mouse&#8221;, &#8220;mutation&#8221;, &#8220;paint&#8221;, &#8220;scroll&#8221;, &#8220;text&#8221;, &#8220;ui&#8221;, and &#8220;xul&#8221;</p>
<p><em>Note: Unfortunately,  this API doesn&#8217;t work propertly. I will contact with Firebug Team and will update about that later. Sorry.</em></p>
<p><u><strong>#14. profile([title]) and profileEnd()</strong></u></p>
<p>Turns on/off the JavaScript profiler. The optional argument title would contain the text to be printed in the header of the profile report.</p>
<p>There are three ways to start Javascript Profiler in Firebug.</p>
<p>Javascript Profiler can be started  ~</p>
<ol>
<li>by clicking &#8220;Profile&#8221; button in Console Toolbar.</li>
<li>by using console.profile(&#8216;My Profiler Title&#8217;)  from Javascript Code</li>
<li>by using profile(&#8216;My Profiler Title&#8217;)  from commandline</li>
</ol>
<p>If you wanna know more about Javascript Profiler in Firebug, please read my previous tutorial (<a href="http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii/">Firebug Tutorial &#8211; Logging, Profiling and CommandLine (Part II)</a>).</p>
<p><strong>Conclusion</strong></p>
<p>This is all about console tab. Even thought it is just a tab, I have to divide my tutorials into three parts (<a href="http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i/">part 1</a>, <a href="http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii/">part 2</a> and this one). Now, I have covered everything about console tab and its functionalities. I hope you will find it useful.</p>
<p>Don&#8217;t hesitate to contact me if you have any suggestion or comment.</p>
<p>Related ~</p>
<ul>
<li><a href="http://michaelsync.net/2007/09/08/firebug-tutorial-overview-of-firebug/">Overview of Firebug</a></li>
<li><a href="http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i/">Firebug Tutorial &#8211; Logging, Profiling and CommandLine (Part I)</a></li>
<li><a href="http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii/">Firebug Tutorial &#8211; Logging, Profiling and CommandLine (Part II)</a></li>
</ul>
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Firebug Tutorial &#8211; Logging, Profiling and CommandLine (Part II)</title>
		<link>http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii</link>
		<comments>http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii#comments</comments>
		<pubDate>Mon, 10 Sep 2007 19:18:03 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii</guid>
		<description><![CDATA[Firebug Tutorial Section 1: Console Tab : Logging, Profiling and CommandLine (Part II) Introduction This tutorial is the part II of &#8220;Firebug Tutorial &#8211; Logging, Profiling and CommandLine&#8220;. (If you haven&#8217;t read the part I of this tutorial, I would...]]></description>
			<content:encoded><![CDATA[<h2>Firebug Tutorial</h2>
<h3>Section 1: Console Tab : Logging, Profiling and CommandLine (Part II)</h3>
<p><strong>Introduction </strong></p>
<p>This tutorial is the part II of &#8220;<a href="http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i/">Firebug Tutorial &#8211; Logging, Profiling and CommandLine</a>&#8220;. (If you haven&#8217;t read the part I of this tutorial, I would recommend you to read <a href="http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i/">the part </a>1 first.)</p>
<p>The following topic will be covered in this section.</p>
<ul>
<li>Javascript Profiler</li>
<li>Tracing error</li>
<li>Tracing XmlHttpRequest object</li>
</ul>
<p><u><strong> #1. Javascript Profiler</strong></u></p>
<p>Javascript Profiler is very useful feature of Firebug for measuring the execution time of each javascript code. It is useful for improving the performance of your code or if you wanna find out why a particular function takes soooo long. It is a bit similar to console.time() that I mentioned already to previous part but Javascript Profiler can give you more detailed information about what&#8217;s happening with your code.</p>
<p>There are three ways to use Javascript Profiler. You can call this function by clicking &#8220;Profile&#8221; button on the toolbar of Firebug console or through code &#8220;console.profile()&#8221; or by typing &#8220;profile()&#8221; in commandline. I will cover first two in this tutorial but not for using profile() in commandline. If you want to know how to use it in commandline, please check-out <a href="http://michaelsync.net/2007/09/15/firebug-tutorial-commandline-api/">this article</a>.</p>
<p><strong>console.profile()<br />
</strong></p>
<ul>
<li>Copy and paste the code in notepad and then, save as a htm file</li>
</ul>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Firebug&lt;/title&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;

function startDoSomething(){
&lt;strong&gt;console.profile('Measuring time');&lt;/strong&gt;
doSomething();
&lt;strong&gt;console.profileEnd();&lt;/strong&gt;
}
function doSomething(){
doThis(1000);
doThis(100000);
doThat(10000);
doThisAndThat(1000,10000);

}
function doThis(count){
for(var i=0;i&amp;lt;count;i++){}
}

function doThat(count){
for(var i=0;i&amp;lt;count;i++){}
}

function doThisAndThat(countThis,countThat){
for(var i=0;i&amp;lt;countThis;i++){ for(var j=0;j&amp;lt;countThat;j++){} }
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
Open the console tab. Click the button below and wait a lit.. &lt;br /&gt;
&lt;input type=&quot;button&quot; value=&quot;Start&quot; onclick=&quot;startDoSomething();&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<ul>
<li>Open this file in Firefox browser.</li>
<li>Open the Console tab on Firebug console.</li>
<li>Click &#8220;Start&#8221; button and wait a lit.. (You will get the result like the screenshot below. )</li>
</ul>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/profiler.jpg" alt="profiler.jpg" /></p>
<p>(The list is sorted based on the execution time.)</p>
<p><strong>Columns and Description of Profiler<br />
</strong></p>
<ul>
<li><strong>Function </strong> column :  It show the name of each function.</li>
<li><strong>Call</strong> column : It shows the count of how many a particular function has been invoked. (2 times for doThis() function in our case. )</li>
<li><strong>Percent</strong> column : It shows the time consuming of each function in percentage.</li>
<li><strong>Own Time </strong>column :  It shows the duration of own script in a particular function. For example: doSomething() function has no its own code. Instead, it is just calling other functions. So, its own execution time will be <strong>0ms </strong>as shown in picture. If you wanna see some values for that column, add some looping in this function.</li>
<li><strong>Time </strong>column : It shows the duration of execution from start point of a function to the end point of a function. For example: doSomething() has no code. So, its own execution time is 0 ms but we call other functions in that function. So, the total execution time of other functions is 923 ms. So, it shows 923 ms in that column. Not clear? Feel free to let me know. I can try once more.. I don&#8217;t mind to explain you again. (That&#8217;s my problem in writing .. I can&#8217;t write very clear..  Sorry about that. )</li>
<li><strong>Avg</strong> column : It shows the average execution time of a particular function. If you are calling a function one time only, you won&#8217;t see the differences. If you are calling more than one time, you will see the differences. Take a look the  doThis() function at second line of picture above.<br />
The formula for that column is  ~<strong><br />
Avg = Own Ttime / Call;</strong></li>
<li><strong>Min</strong> column and <strong>Max </strong>column: It shows the minimum execution time of a particular function. In our example, we call doThis() function twice. When we passed 1000 as an parameter, it probably took only a few millisecond. (let&#8217;s say 1 ms.). then, we passed 100000 to that function again. It took much longer than first time. (let&#8217;s say 50 ms.) . So, in that case, &#8220;1 ms&#8221; will be shown in Min column and &#8220;50 ms&#8221; will be shown in Max column.</li>
<li><strong>File</strong> column : the file name of file where the function located.</li>
</ul>
<p>Note: You can set the title of profiler by passing one string to console.profile() function. In our example (console.profile(&#8216;Measuring time&#8217;);), &#8216;Measuring time&#8217; is the title of profiler.<br />
<strong>Profiler button from Console tab&#8217;s toolbar<br />
</strong></p>
<p>If you don&#8217;t want to profile thru the code, you can use &#8220;Profile&#8221; button from the toolbar of Firebug console.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/toolbar-console.jpg" alt="toolbar-console.jpg" /></p>
<p>In order to test this,</p>
<ul>
<li> you need to remove two lines (console.profile(&#8216;Measuring time&#8217;); and console.profileEnd();)  from doSomething() function.</li>
<li>Open this file in Firefox.</li>
<li>Open Console tab of Firebug console.</li>
<li>Click &#8220;Profile&#8221; button ( right button on the toolbar of Firebug console.)</li>
<li>Click &#8220;Start&#8221; button on your page.</li>
<li>Wait for 1 min ( or a lit less than that.)</li>
<li>Click &#8220;Profile&#8221; button again. ( You will get the same graph as the picture above.)</li>
</ul>
<p>That&#8217;s all about Javascript Profiler. Let me know if you have any question or comment.</p>
<p>Okay. Let&#8217;s move on to next topic.</p>
<p><strong><u>#2. Options of Console tab</u><br />
</strong></p>
<p>There is one link called &#8220;Options&#8221;  at the right-side of Firebug console. If you click this link, you will see the menu as shown in picture below.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/menu-of-console-tab.jpg" alt="menu-of-console-tab.jpg" /></p>
<p>I will divided those times in three categories.</p>
<ol>
<li><strong>Errors Tracing</strong>
<ol>
<li>Show Javascript Error</li>
<li>Show Javascript Warnings</li>
<li>Show CSS Errors</li>
<li>Show XML Errors</li>
</ol>
</li>
<li><strong>XmlHttpRequest Tracing </strong>
<ol>
<li>Show XMLHttpRequests</li>
</ol>
</li>
<li><strong>CommandLine</strong>
<ol>
<li>Larger Command Line</li>
</ol>
</li>
</ol>
<p><u><strong>#2.1 Errors Tracing and Filtering<br />
</strong></u></p>
<ul>
<li><strong>Show Javascript Errors</strong></li>
<li><strong>Show Javascript Warning</strong></li>
<li><strong>Show CSS Errors</strong></li>
<li><strong>Show XML Errors</strong></li>
</ul>
<p>Those options are used for tracing the errors of your script, style sheet and XML. You can also filter the error messages based on the type of error that you wanna.</p>
<p>Example Code</p>
<pre class="brush: jscript; title: ; notranslate">

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Firebug&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
.normalText{
bcolor : red;  /* This is ERROR!! */
}
&lt;/style&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
function foo(){
var objTxt = doucmnet.getElementById('nameTextBox');  //This is ERROR!!
alert(objTxt.value);
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;input id=&quot;nameTextBox&quot; class=&quot;normalText&quot; type=&quot;text&quot; /&gt;
&lt;input type=&quot;button&quot; value=&quot;Start&quot; onclick=&quot;foo();&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Output ~</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/error.jpg" alt="error.jpg" /></p>
<ul>
<li>Copy and paste the code in notepage.</li>
<li>Save as a .htm file.</li>
<li>Check &#8220;Shows Javascript errors&#8221; and &#8220;Shows CSS errors&#8221; on Console tab.</li>
<li>Reload the page</li>
<li>First, you will get the CSS error. ( Reason : We wrote bcolor instead of color in &#8220;normalText&#8221; class. )</li>
<li>Click the button</li>
<li>then, we will get the another error. ( because we wrote &#8220;doucmnet&#8221; instead of &#8220;document&#8221; in the code. )</li>
</ul>
<p>I think those options are very sample to use. If you wanna see the errors, just check the option in menu. then, Firebug will give very good information about the errors that you are getting. Uncheck it if you don&#8217;t want.</p>
<p><u><strong>#2.2. Tracing XmlHttpRequest object </strong></u></p>
<p>This is also one of the most popular feature of Firebug and it is really helpful for Ajax developer. The problem with Ajax is that it is very difficult to figure out if something goes wrong in XmlHttpRequest. Sometimes, you have no idea about what&#8217;s going on behind the sense while the indicator keep on cycling all the time. One of the problem that I face when I was playing around with ajax, it is difficult to find out whether the response format from Web service are correct or not.</p>
<p>but things are very simple with Firebug. You only need to select &#8220;Show XmlHttpRequest&#8221; option. Firebug will tell the following thing.</p>
<ol>
<li>The execution time</li>
<li>Parameters (QueryString)</li>
<li>HTTP Header</li>
<li>Response</li>
</ol>
<p>Example : I used Yahoo UI DataTable in this sample. This sample is the updated version of <a href="http://developer.yahoo.com/yui/examples/datatable/dt_xhrlocalxml.html">this sample</a> from Yahoo UI.</p>
<p>Download : <a href="http://www.esnips.com/doc/6f0782e7-b818-4a29-9afd-6523166afdc8/yui-php/">SourceCode</a></p>
<ul>
<li> Download the zip file from the link above</li>
<li>Extract the zip file and put all files to PHP directory.</li>
<li>Try to call this file &#8220;dt_xhrlocalxml_clean.html&#8221; from Firefox ( http://localhost/yui-php/dt_xhrlocalxml_clean.html in my case.)</li>
<li>Open the Console tab in Firebug console.</li>
<li>Select &#8220;Show XmlHttpRequests&#8221; option</li>
<li>Click the button &#8220;Load Data&#8221; on the page</li>
<li>The following result as shown in picture will be shown. (The style might be a lit bit different since I didn&#8217;t change the path in some CSS files. )</li>
</ul>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/datatable.jpg" alt="datatable.jpg" /></p>
<ul>
<li> And check the Console tab in Firebug console.</li>
<li>You will the detailed response in XML format as shown in the picture below.</li>
</ul>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/httprequest.jpg" alt="httprequest.jpg" /></p>
<p>Note: If you don&#8217;t wanna download or if you don&#8217;t have PHP installed on your machine, you may try to check <a href="http://developer.yahoo.com/yui/examples/datatable/dt_xhrlocalxml.html">this online sample</a> from Yahoo.  But there won&#8217;t be any button so you should select the &#8220;Show XmlHttpRequests&#8221; option first and reload or open the link&#8230;</p>
<p>Okay. That&#8217;s all for today. I was thinking to write about CommandLine in this part but I don&#8217;t have the enough time to write it today. Don&#8217;t worry. I will tell about CommandLine tomorrow.</p>
<p>Cya. Don&#8217;t hesitate to drop a comment if you have any suggestion or comment.  I appreciate it.
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2007/09/10/firebug-tutorial-logging-profiling-and-commandline-part-ii/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Firebug Tutorial &#8211; Logging, Profiling and CommandLine (Part I)</title>
		<link>http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i</link>
		<comments>http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i#comments</comments>
		<pubDate>Sun, 09 Sep 2007 13:27:50 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i</guid>
		<description><![CDATA[Firebug Tutorial Section 1: Console Tab : Logging, Profiling and CommandLine (Part II) Overview of Console Tab This tab is mainly used for logging. It also can be used as CommandLine window (like immediate window in Microsoft Visual Studio) while...]]></description>
			<content:encoded><![CDATA[<h2>Firebug Tutorial</h2>
<h3>Section 1: Console Tab : Logging, Profiling and CommandLine (Part II)</h3>
<p><strong>Overview of Console Tab</strong></p>
<p>This tab is mainly used for logging. It also can be used as CommandLine window (like immediate window in Microsoft Visual Studio) while you are debugging the Javascript. It can be used for monitoring the execution of Javascript code by using Profiling service.</p>
<p>The following topic will be covered in this section.</p>
<ul>
<li>Logging in Firebug (with String Substitution pattern )</li>
<li>Grouping the logs or messages</li>
<li>console.dir and console.dirxml</li>
<li>Assertion ( console.assert() )</li>
<li>Tracing ( console.trace() )</li>
<li>Timing ( Measuring the time of your code)</li>
<li>Javascript Profiler (An introduction in this tutorial, the details will be covered in next tutorial.)</li>
</ul>
<p><strong>#1. Logging in Firebug</strong></p>
<p>Firebug supports logging in Console tab. So, you don&#8217;t need to use alert(&#8216;something&#8217;) or document.write(&#8216;something&#8217;) anymore.</p>
<p>There are five types of logging in Firebug.</p>
<ul>
<li>console.log  : Write a message without icon.</li>
<li>console.debug : Writes a message to the console, including a hyperlink to the line where it was called</li>
<li><img src="http://michaelsync.net/wp-content/uploads/2007/09/erroricon.png" alt="erroricon.png" />  console.error() : Writes a message to the console with the visual &#8220;error&#8221; icon and color coding and a hyperlink to the line where it was called.</li>
<li><img src="http://michaelsync.net/wp-content/uploads/2007/09/infoicon.png" alt="infoicon.png" />  console.info() : Writes a message to the console with the visual &#8220;info&#8221; icon and color coding and a hyperlink to the line where it was called.</li>
<li><img src="http://michaelsync.net/wp-content/uploads/2007/09/warningicon.png" alt="warningicon.png" />  console.warn() : Writes a message to the console with the visual &#8220;warning&#8221; icon and color coding and a hyperlink to the line where it was called.</li>
</ul>
<p>Example Code:</p>
<ul>
<li>Open the htm file called &#8220;Plain HTML&#8221; or create one HTML file.</li>
<li>Paste the following code with &lt;body&gt;  tag.</li>
</ul>
<pre class="brush: jscript; title: ; notranslate">
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
console.log('This is log message');
console.debug('This is debug message');
console.error('This is error message');
console.info('This is info message');
console.warn('This is warning message');
&lt;/script&gt;
</pre>
<p>You will get the following output. If you click on hyperlink (&#8220;test.htm&#8221; in this case), it will take you to script tab and will highlight the line that wrote this message.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/basic-logging-concept.jpg" alt="basic-logging-concept.jpg" /></p>
<p><strong>String Substitution Patterns</strong></p>
<p>String substitution parterns can be used in console.log, console.info, console.debug, console.warn and console.error . You can use the same way that we used in C/C++.</p>
<table border="0" cellpadding="0" cellspacing="5">
<tr>
<td>%s</td>
<td>String</td>
</tr>
<tr>
<td>%d, %i</td>
<td>Integer (numeric formatting is not yet supported)</td>
</tr>
<tr>
<td>%f</td>
<td>Floating point number (numeric formatting is not yet supported)</td>
</tr>
<tr>
<td>%o</td>
<td>Object hyperlink</td>
</tr>
</table>
<p>Example :</p>
<p>Note: I will use console.log in the example below even all console objects (console.log, console.info, console.debug, console.warn and console.error ) support string substitution.</p>
<ul>
<li>Remove &#8220;script&#8221; tag that we pasted for the previous example.</li>
<li>Paste the code below within &lt;body&gt; tag.</li>
</ul>
<pre class="brush: jscript; title: ; notranslate">
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;

//This is for normal string substitution &quot; %s, %d, %i, %f&quot;.
console.log(&quot;My Name is &lt;strong&gt;%s&lt;/strong&gt;. My Date of Birth is &lt;strong&gt;%dth %s, %i&lt;/strong&gt;. My height is &lt;strong&gt;%f&lt;/strong&gt; m.&quot;, &quot;Nicolas Cage&quot;, 7, 'January', 1964, 1.8542);

function Foo(){
this.LeftHand = function(){
return &quot;Left Hand&quot;;
}
this.RightHand = function(){
return &quot;Right Hand&quot;;
}
}

//This is for object &quot;%o&quot;.
var objFoo = new Foo();
console.log('This is &lt;strong&gt;%o&lt;/strong&gt; of Foo class.', objFoo);

&lt;/script&gt;
</pre>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/console-string-substitution1.jpg" alt="console-string-substitution1.jpg" /></p>
<p>If you are using <strong>%o</strong> in your log, the object will be shown as a hyperlink in green color. This hyperlink is linked to the DOM tab. So, If you click &#8220;object&#8221; in second line, you will see the list of properties of that object (LeftHand and RightHand in this case.)</p>
<p><strong>#2. Grouping</strong></p>
<p>Firebug allows you to group the message or log in Console tab. If you have some many logs in your code, you can probably divide your log into small group or subgroup</p>
<p>Example ~</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;

var groupname = 'group1';
console.group(&quot;message group : %s &quot; , groupname);
console.log(&quot;log message 1 from %s&quot;, groupname);
console.log(&quot;log message 2 from %s&quot;, groupname);
console.log(&quot;log message 3 from %s&quot;, groupname);
console.groupEnd();

groupname = 'group2';
console.group(&quot;message group : %s &quot; , groupname);
console.log(&quot;log message 1 from %s&quot;, groupname);

var subgroupname = 'subgroup1';
console.group(&quot;message group : %s &quot; , subgroupname);
console.log(&quot;log message 1 from %s&quot;, subgroupname);
console.log(&quot;log message 2 from %s&quot;, subgroupname);
console.log(&quot;log message 3 from %s&quot;, subgroupname);
console.groupEnd();

console.log(&quot;log message 3 from %s&quot;, groupname);
console.groupEnd();

&lt;/script&gt;
</pre>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/group-message.jpg" alt="group-message.jpg" /></p>
<p><strong>#3. console.dir and console.dirxml<br />
</strong></p>
<ul>
<li><strong>console.dir</strong> : It can be used for getting all properties and methods of a particular object. According the example below, we can get the Model (property) and getManufactor (method) of Car object by using console.dir(); You can also pass the object of HTML element (eg: console.dir(document.getElementById(&#8216;tbl1&#8242;)); ) instead of objCar and let&#8217;s see the result. (You will get all properties and methods of the HTML table called &#8220;tbl1&#8243;).</li>
<li><strong>console.dirxml</strong> : print the XML source tree of HTML element.</li>
</ul>
<pre class="brush: jscript; title: ; notranslate">
&lt;table id=&quot;tbl1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot;&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
//Create a class
function Car(){
this.Model = &quot;Old Model&quot;;

this.getManufactor = new function(){
return &quot;Toyota&quot;;
}
}

//Create a object
var objCar = new Car();

//Firebug
console.dir(objCar);
console.dirxml(document.getElementById('tbl1'));

&lt;/script&gt;
</pre>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/console-dir.jpg" alt="console-dir.jpg" /></p>
<p><strong>#4. Assertion ( console.assert() )</strong></p>
<p>You can use console.assert() to test whether an expression is true or not. If the expression is false, it will write a message to the console and throw an exception.</p>
<p>Example :</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
function whatIsMyAge(year){
var currYear = 2007;
return currYear - year;
}

var yearOfBirth1 = 1982;
var age1 = 25;
console.assert(whatIsMyAge(yearOfBirth1) == age1);

var yearOfBirth2 = 1982;
var age2 = 11;
console.assert(whatIsMyAge(yearOfBirth2) == age2); //You should get the error here.
&lt;/script&gt;
</pre>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/assertion-failure.jpg" alt="assertion-failure.jpg" /></p>
<p><strong>#5. Tracing ( console.trace() )</strong></p>
<p>This function is very interesting. Before I tell you the way that I understand, let&#8217;s take a look what console.trace does exactly in official website.</p>
<blockquote>
<h3>console.trace()</h3>
<p>Prints an interactive stack trace of JavaScript execution at the point where it is called.</p>
<p>The stack trace details the functions on the stack, as well as the values that were passed as arguments to each function. You can click each function to take you to its source in the Script tab, and click each argument value to inspect it in the DOM or HTML tabs.</p></blockquote>
<p>This function will tell you about the route information from start point to end point. If you are not clear what I mean, let&#8217;s take a look at the sample code and the result.</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Firebug&lt;/title&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
function startTrace(str){
return method1(100,200);
}
function method1(arg1,arg2){
return method2(arg1 + arg2 + 100);
}
function method2(arg1){
var var1 = arg1 / 100;
return method3(var1);
}
function method3(arg1){
console.trace();
var total = arg1 * 100;
return total;
}

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type=&quot;button&quot; value=&quot;Trace&quot; onclick=&quot;startTrace('Result');&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/trace.jpg" alt="trace.jpg" /></p>
<p>Suppose: we wanna know how &#8220;method3&#8243; function is invoked. So, we put this code &#8220;console.trace()&#8221; in that method. then, we run the program and we got the result as picture above. If we read the result from bottom to top, we will see &#8220;onclick(click clientX=34, clientY=26)&#8221;. That means the execution of Javascript started at on click event of button. then, we got &#8220;startTrace(&#8220;Result&#8221;)&#8221; in second line. That means startTrace function is invoked after firing onclick event and the parameter is &#8220;Result&#8221;. If we keep on checking from bottom to top, we will figure out the completed route from onclick event to method3.</p>
<p>If you wanna test more, you can move this code &#8220;console.trace()&#8221;  to method2(). then, firebug will give the new route from onclick event which is a started point to method2() which is the end point.</p>
<p>I think that it&#8217;s pretty useful if you are debugging the other developer&#8217;s source code and you have no idea why this function is invoked.</p>
<p>Let me know if you are not clear what I&#8217;m trying to explain about console.trace();.</p>
<p><strong>#6. Timing ( Measuring the time of your code) </strong></p>
<p>You can use console.time(timeName) function to measure how long a particular code or function take. This feature is very helpful if you are trying to improve the performance of your Javascript code.</p>
<p>Example :</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
&lt;title&gt;Firebug&lt;/title&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
function measuretheTime(){
var timeName = 'measuringTime';
console.time(timeName);

for(var i=0;i&amp;lt;1000;i++){
///do something
for(var j=0;j&amp;lt;100;j++){
//do another thing.
}
}

console.timeEnd(timeName);
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type=&quot;button&quot; value=&quot;Trace&quot; onclick=&quot;measuretheTime();&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Result : <span class="objectBox objectBox-text">measuringTime: 16ms </span></p>
<p><strong>#7. Javascript Profiler</strong></p>
<p>You can start the profiler thought code (console.profile(&#8216;profileName&#8217;)) or by clicking &#8220;Profile&#8221; button from &#8220;Console&#8221; tag. It can be used for improving the performance of Javascript. It is similiar to the console.time() function but profiler can give your more advanced and detailed information.</p>
<p>I will tell you about this more details in next tutorial (Part2) . I hope you all are clear about this tutorial. If you have any comment or suggestion, please drop a comment.. Thanks. C ya tomorrow.</p>
<p>Reference ~</p>
<ul>
<li><a href="http://getfirebug.com/console.html" title="Learn about special functions you can call from web pages." target="_blank">Console API</a></li>
</ul>
<p><a href="http://getfirebug.com/commandline.html" title="Learn about special functions you can use on the command line."><br />
</a>
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2007/09/09/firebug-tutorial-logging-profiling-and-commandline-part-i/feed</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
		<item>
		<title>Firebug Tutorial &#8211; Overview of Firebug</title>
		<link>http://michaelsync.net/2007/09/08/firebug-tutorial-overview-of-firebug</link>
		<comments>http://michaelsync.net/2007/09/08/firebug-tutorial-overview-of-firebug#comments</comments>
		<pubDate>Sat, 08 Sep 2007 15:26:54 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2007/09/08/firebug-tutorial-overview-of-firebug</guid>
		<description><![CDATA[A few words from me It has been over 1 year that I&#8217;m using Firebug in web development. I found it very useful. I&#8217;m really thank to SangSing who introduces me about Firebug. I used to encourage a lot of...]]></description>
			<content:encoded><![CDATA[<p><img src="http://michaelsync.net/wp-content/uploads/2007/05/header.png" align="texttop" /><br />
<strong>A few words from me </strong></p>
<p>It has been over 1 year that I&#8217;m using Firebug in web development. I found it very useful. I&#8217;m really thank to <a href="http://www.javapassion.com/ajaxcodecamp/">SangSing </a>who introduces me about Firebug. I used to encourage a lot of my techie friends to use Firebug but they said that they don&#8217;t know how to use it. They told me that they wanna get something that include all features of firebug and examples. I googled a lit bit but I didn&#8217;t find nice resources that covers everything about firebug. So, I decided to write this tutorial. I will try to cover all features of firebug as much as I can. I will show each features with sample sourcecode and screenshot if it required. <em>Don&#8217;t hesitate to contact me if you have any suggestion or comment. </em></p>
<p>There are 5 sections in this tutorial.</p>
<ul>
<li><strong>Section 1: Overview of Firebug</strong> :  An introduction of Firebug and feature lists, how to install it and a few notes</li>
</ul>
<ul>
<li><strong>Section 2: Logging, Tracing and CommandLine</strong> : Everything related to Console tab. An introduction of CommandLine windows which is the same as Immediate windows or Watch window  from Visual Studio.</li>
</ul>
<ul>
<li><strong>Section 3: HTML DOM Inspector and HTML CRUD operation</strong>  : This section will tell you about what HTML inspecting is, how to inspect the HTML element, why it is useful and etc. I will also show you how to create/update/delete the HTML DOM dynamically in HTML tab.</li>
</ul>
<ul>
<li><strong>Section 4: Javascript debugging with Firebug</strong> : This section will cover everything about javascript debugging which is the most famous feature of Firebug. It will also show you how to use Console tab while debugging the Javascript.</li>
</ul>
<ul>
<li><strong>Section 5: CSS, DOM and Net Tab</strong> : (I haven&#8217;t decided whether I should write about them in one section or not.  )</li>
</ul>
<p>As I said above, I will try to cover as much as possible. If I miss out something in this tutorial, please let me know. I appreciated it.</p>
<p><strong>Getting Started </strong>: <strong>Overview of Firebug</strong></p>
<p><em>Note: I will cover some basic understanding about firebug and its features, installation and a few screenshots in this section. So, if you already have some ideas about Firebug,  you may probably skip this section. </em></p>
<p><a href="http://www.getfirebug.com/?link=2" title="Firebug is a free web development tool for Firefox"><img src="http://www.getfirebug.com/images/firebug2.png" alt="Firebug - Web Development Evolved" border="0" /></a></p>
<p><strong>What is Firebug?</strong></p>
<p>Firebug is one of the most popular Mozilla Firefox&#8217;s extensions (a.k.a addon). It is also a tool that make the web developers&#8217; life easier. It includes a lot of cool features such as debugging, HTML inspecting, profiling and etc which are very useful for web development.</p>
<p><strong>Features</strong></p>
<ul>
<li><strong>Javascript debugging</strong></li>
<li><strong>Javascript CommandLine<br />
</strong></li>
<li><strong>Monitor the Javascrit Performance and XmlHttpRequest</strong></li>
<li><strong>Logging<br />
</strong></li>
<li><strong>Tracing</strong></li>
<li><strong>Inspect HTML and Edit HTML<br />
</strong></li>
<li><strong>Edit CSS</strong></li>
</ul>
<p><strong>Where to get Firebug Addon?</strong></p>
<ul>
<li>Go to the official firebug website <a href="http://getfirebug.com/">http://getfirebug.com</a> .</li>
<li>There is the image as below at the right-side of the firebug website. Click this image to install.</li>
</ul>
<p style="text-align:center;"><img src="http://michaelsync.net/wp-content/uploads/2007/09/install-firebug.jpg" alt="Click to install Firebug" /></p>
<ul>
<li>The following dialog will be shown after clicking the image above. Click to &#8220;Install Now&#8221;  button.</li>
</ul>
<p style="text-align:center;"><img src="http://michaelsync.net/wp-content/uploads/2007/09/install-firebug-dialog.jpg" alt="Firebug - Software Installation" /></p>
<ul>
<li>After the installation is completed, you need to restart the browser.</li>
</ul>
<p><strong>Screenshots</strong></p>
<p><strong>Main Menu </strong>(under &#8220;Tools&#8221; Menu)</p>
<p>&#8220;Firebug&#8221; and &#8220;Error Console&#8221; menu will be shown under &#8220;Tools&#8221; menu of Firefox.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/firebug-menu-under-tool-menu.jpg" alt="firebug-menu-under-tool-menu.jpg" /></p>
<ul>
<li><strong>Firebug</strong> : It is just a placeholder for Firebug&#8217;s submenus.</li>
<li><strong>Error Console</strong> : If you click this menu, one console window will be launched with the list of errors, warnings and message. Actually, this error console is the same as the console tab from Firebug console.</li>
</ul>
<p><strong>Firebug Menu</strong></p>
<p>If you click &#8220;Firebug&#8221;  menu under &#8220;Tools&#8221;, the following submenus will be shown.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/firebug-menu-under-firebug-menu.jpg" alt="firebug-menu-under-firebug-menu.jpg" /></p>
<ul>
<li><strong>Open Firebug</strong> : Open the firebug console within the browser. If you don&#8217;t wanna click this menu, you can simply press &#8220;F12&#8243; to open the firebug console.</li>
<li><strong>Open Firebug in New Window</strong> : Open the firebug console in separated window.</li>
<li><strong>Disable Firebug</strong> : It is for disabling firebug. This option is very important. You should disable the firebug if you don&#8217;t need it because If you don&#8217;t disable the firebug, it might be a lit bit slow to surf the Ajax-enabled websites like GMail.</li>
<li><strong>Disable Firebug for **** </strong>: You can disable the specific website instead of disabling the whole firebug.</li>
<li><strong>Allowed Sites</strong> : You can add the list of website that you want to surf with Firebug enabled option.</li>
<li><strong>Inspect the Element</strong> : This menu is for inspecting the HTML element. Please read more about this in section 3.</li>
<li><strong>Profile Javascript</strong> : This option is available in Firebug enabled mode only. It is used for monitoring the execution of javascript code. This option is really useful when you have performance issue with your code. Please read more about this in Section 4.</li>
<li><strong>Clear Console</strong> : Clear the console tab of Firebug console.</li>
<li><strong>CommandLine</strong> : Open the console tab</li>
<li>Search : Set the focus to the Search textbox of current tab.</li>
</ul>
<p><strong>Content Menu</strong></p>
<p>There is only one menu called &#8220;Inspect Element&#8221; in content menu. This menu is very useful. Please read more about this in Section 3.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/inspect-element-on-content-menu.jpg" alt="inspect-element-on-content-menu.jpg" /></p>
<p><strong>Firebug Console</strong></p>
<p>The picture below is Firebug console.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/firebug-console.jpg" alt="Firebug Console" /></p>
<p>It contains six tabs such as Console tab, HTML tab, CSS tab, Script tab, DOM tab and Net tab.</p>
<ul>
<li><strong>Console tab</strong> : It is for logging, profiling, tracing and commandline.</li>
<li><strong>HTML tab</strong> : It is for inspecting HTML element, editing HTML and changing the stylesheet at runtime. CSS, Layout and DOM console are already included as the subtabs.</li>
<li><strong>CSS tab</strong> : You can check how many css file included in the webpage easily. You can simply select the CSS file that you like and you can made the changes to that file on the fly. (I don&#8217;t use that tab that much since the same one is already included in HTML tab. )</li>
<li><strong>Script tab</strong> : It is for debugging Javascript code. Watch and Breakpoints consoles are the subtab of Script tab.</li>
<li><strong>DOM tab</strong> : It is for exploring DOM. (I don&#8217;t use that tab that much. Instead, I used to use DOM tab from HTML console and Script tab.)</li>
<li><strong>Net tab</strong> : It is for monitoring network activities. It helps you to know why your page (or a particular webpage) is taking so long to load in the browser.</li>
</ul>
<p><strong>Status Bar</strong></p>
<p>You will see the green cycle if there is no error on your page.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/green-cycle-on-status-bar.jpg" alt="green-cycle-on-status-bar.jpg" /></p>
<p>You will see the red cycle and the count of errors if there is some errors in your page.</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/09/red-cycle-on-status-bar.jpg" alt="red-cycle-on-status-bar.jpg" /></p>
<p><strong>Keyboard and Mouse Shortcuts</strong></p>
<p>F12. I used to use only F12 to open/close the Firebug console.</p>
<p>If you wanna read the completed list of shortcuts, you can check-out <a href="http://getfirebug.com/keyboard.html" title="Keyboard and Mouse Shortcuts">here</a>.</p>
<p><strong>Problem?</strong></p>
<p>Please check-out <a href="http://getfirebug.com/faq.html" title="Frequently Asked Questions ">this FAQ page</a>.</p>
<p>If you still have problems, you drop a comment in my blog. I will reply as soon as possible. Or you can probably contact with <a href="http://groups.google.com/group/firebug">Firebug User Group</a>.</p>
<p><strong>Conclusion</strong></p>
<p>That&#8217;s all. :) I think you now have some ideas about what firebug is, how it looks like and how to install. If you are already familiar with firebug, this section will be too plain for you since I didn&#8217;t put anything new in this section. I will tell you more details about each tab in next section. So, come back tomorrow!!</p>
<p>Feel free to let me know if you have any idea or comment about this tutorials. Your comment will make this tutorials better. I appreciate it.
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2007/09/08/firebug-tutorial-overview-of-firebug&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2007/09/08/firebug-tutorial-overview-of-firebug/feed</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>8 Steps to create your owned Firefox Extension</title>
		<link>http://michaelsync.net/2006/12/06/8-steps-to-create-your-owned-firefox-extension</link>
		<comments>http://michaelsync.net/2006/12/06/8-steps-to-create-your-owned-firefox-extension#comments</comments>
		<pubDate>Wed, 06 Dec 2006 14:02:18 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2006/12/06/8-steps-to-create-your-owned-firefox-extension</guid>
		<description><![CDATA[This article illustrates how to create a Firefox extension in very simple way. It&#8217;s just 8 steps to fellow then you will get some ideas how to create your owned one.I think, it might be useful for those who wanna...]]></description>
			<content:encoded><![CDATA[<p>This article illustrates how to create a Firefox extension in very simple way. It&#8217;s just 8 steps to fellow then you will get some ideas how to create your owned one.I think, it might be useful for those who wanna create their Firefox Extensions.</p>
<p>This article is based on <a href="http://developer.mozilla.org/en/docs/Building_an_Extension">this</a> article from <a href="http://developer.mozilla.org">developer.mozilla.org</a>. So, All credits go to the original article &#8220;<a href="http://developer.mozilla.org/en/docs/Building_an_Extension">Building an Extension</a>&#8220;.</p>
<p>Maybe. you might ask me why I wrote duplicated one.<br />
Well. There are two reasons behind. First thing is that I&#8217;m looking a lit bit more details into <a href="http://www.getfirebug.com/">Firebug Extension</a> so that I have to know how to create an extension for firefox. (At least, simply) and also, I have to take a note all steps so that I don&#8217;t need to look the whole article again. Second reason is that the original article was written for all platforms so that it might be a lit bit complicated than this one I wrote. :) All steps in this article are tested in Windows XP sp2 and Firefox 2.0.</p>
<p>Let&#8217;s start!</p>
<h4>Step #1</h4>
<p>Create a folder for your extension somewhere on your hard disk<br />
<em>e.g. C:\extensions\myExtension\</em></p>
<h4>Step #2</h4>
<p>Create another folder called <strong>chrome</strong> under your extension folder<br />
<em>e.g. C:\extensions\myExtension\chrome</em></p>
<h4>Step #3</h4>
<p>Create another folder called <strong>content</strong> under chrome folder<br />
<em>e.g. C:\extensions\myExtension\chrome\content</em></p>
<h4>Step #4</h4>
<p>Create two new empty text files, one called <strong>chrome.manifest</strong> and the other called <strong>install.rdf</strong>.<br />
e.g. C:\extensions\myExtension\chrome.manifest<br />
e.g. C:\extensions\myExtension\install.rdf</p>
<p>Note: I would suggest to unhide all extensions of all file in your harddisk. If you are not sure how to do it, you can check as follow.</p>
<ol>
<li>Open &#8220;C:\&#8221; drive.</li>
<li>Go to <strong>Tools-&gt;Folder Options</strong>.</li>
<li>Go to <strong>View </strong>Tab.</li>
<li>Uncheck &#8220;<strong>Hide extensions for known file types</strong>&#8220;</li>
</ol>
<h4>Step #5</h4>
<p>Open the file called <strong>install.rdf</strong> (<em>e.g. C:\extensions\myExtension\install.rdf</em>). Copy the following code and paste it to <strong>install.rdf</strong> file.</p>
<pre>
<font face="Courier New" size="2"><font color="#0000ff">&lt;?</font><font color="#800000">xml</font><font color="#ff0000">version</font><font color="#0000ff">=</font>"<font color="#0000ff">1.0</font>"<font color="#0000ff">?&gt;</font>

<font color="#0000ff">&lt;</font><font color="#800000">RDF</font><font color="#ff0000">xmlns</font><font color="#0000ff">="http://www.w3.org/1999/02/22-rdf-syntax-ns#"</font> <font color="#ff0000">xmlns:em</font><font color="#0000ff">="http://www.mozilla.org/2004/em-rdf#"&gt;</font>
<font color="#0000ff">&lt;</font><font color="#800000">Description </font><font color="#ff0000">about</font><font color="#0000ff">=</font>"<font color="#0000ff">urn:mozilla:install-manifest</font>"<font color="#0000ff">&gt;</font>
<font color="#0000ff">  &lt;</font><font color="#800000">em:id</font><font color="#0000ff">&gt;</font>sample@foo.net<font color="#0000ff">&lt;/</font><font color="#800000">em:id</font><font color="#0000ff">&gt;</font>
<font color="#0000ff">  &lt;</font><font color="#800000">em:version</font><font color="#0000ff">&gt;</font>1.0<font color="#0000ff">&lt;/</font><font color="#800000">em:version</font><font color="#0000ff">&gt;</font>
<font color="#0000ff">  &lt;</font><font color="#800000">em:type</font><font color="#0000ff">&gt;</font>2<font color="#0000ff">&lt;/</font><font color="#800000">em:type</font><font color="#0000ff">&gt;</font>

<font color="#0000ff">  &lt;!--</font> <font color="#008000">Target pplication this extension can install into,
       with minimum and maximum supported versions</font>.
<font color="#0000ff">   --&gt; </font>
<font color="#0000ff">  &lt;</font><font color="#800000">em:targetApplication</font><font color="#0000ff">&gt;</font>
   <font color="#0000ff">&lt;</font><font color="#800000">Description</font><font color="#0000ff">&gt;</font>
    <font color="#0000ff">&lt;</font><font color="#800000">em:id</font><font color="#0000ff">&gt;</font>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}<font color="#0000ff">&lt;/</font><font color="#800000">em:id</font><font color="#0000ff">&gt;</font>
    <font color="#0000ff">&lt;</font><font color="#800000">em:minVersion</font><font color="#0000ff">&gt;</font>1.5<font color="#0000ff">&lt;/</font><font color="#800000">em:minVersion</font><font color="#0000ff">&gt;</font>
    <font color="#0000ff">&lt;</font><font color="#800000">em:maxVersion</font><font color="#0000ff">&gt;</font>2.0.0.*<font color="#0000ff">&lt;</font>/<font color="#800000">em:maxVersion</font><font color="#0000ff">&gt;</font>
   <font color="#0000ff">&lt;/</font><font color="#800000">Description</font><font color="#0000ff">&gt;</font>
  <font color="#0000ff">&lt;/</font><font color="#800000">em:targetApplication</font><font color="#0000ff">&gt;</font>

<font color="#0000ff">&lt;!--</font> <font color="#008000">Front End MetaData</font> --&gt;
<font color="#0000ff">&lt;</font><font color="#800000">em:name</font><font color="#0000ff">&gt;</font>Sample!<font color="#0000ff">&lt;/</font><font color="#800000">em:name</font><font color="#0000ff">&gt;</font>
<font color="#0000ff">&lt;</font><font color="#800000">em:description</font><font color="#0000ff">&gt;</font>A test extension<font color="#0000ff">&lt;/</font><font color="#800000">em:description</font><font color="#0000ff">&gt;</font>
<font color="#0000ff">&lt;</font><font color="#800000">em:creator</font><font color="#0000ff">&gt;</font>Your Name Here<font color="#0000ff">&lt;/</font><font color="#800000">em:creator</font><font color="#0000ff">&gt;</font>
<font color="#0000ff">&lt;</font><font color="#800000">em:homepageURL</font><font color="#0000ff">&gt;</font><u>http://www.foo.com/</u><font color="#0000ff">&lt;/</font><font color="#800000">em:homepageURL</font><font color="#0000ff">&gt;</font>
<font color="#0000ff">&lt;/</font><font color="#800000">Description</font><font color="#0000ff">&gt;</font>
<font color="#0000ff">&lt;/</font>RDF<font color="#0000ff">&gt;</font></font></pre>
<p><em> Properties and Description</em></p>
<ul>
<li>sample@foo.net &#8211; the ID of the extension. This is some value you come up with to identify your extension in email address format (note that it should not be your email). Make it unique. You could also use a GUID.</li>
<li>Specify<br />
<em>2</em> &#8212; the 2 declares that it is installing an extension. If you were to install a theme it would be 4 (see Install Manifests#type for other type codes).</li>
<li>{ec8030f7-c20a-464f-9b0e-13a3a9e97384} &#8211; Firefox&#8217;s application ID.</li>
<li>1.5 &#8211; the minimum version of Firefox you&#8217;re saying this extension will work with. Set this as the minimum version you&#8217;re going to commit to testing and fixing bugs with.</li>
<li>2.0.0.* &#8211; the maximum version of Firefox you&#8217;re saying this extension will work with. Set this to be no newer than the newest currently available version! In this case, &#8220;2.0.0.*&#8221; indicates that the extension works with versions of Firefox 2.0.0.0 through 2.0.0.x.</li>
</ul>
<p>Extensions designed to work with Firefox 1.5.0.x at the latest should set the maximum version to &#8220;1.5.0.*&#8221;.<br />
See Install Manifests for a <a href="http://developer.mozilla.org/en/docs/Install_Manifests">complete listing</a> of the required and optional properties.<br />
Save the file.</p>
<h4>Step #6</h4>
<p>Create a text file called <strong>sample.xul</strong> under chrome/content. (e.g:  C:\extensions\myExtension\content\sample.xul ). Copy this sample code above and paste it into <strong>sample.xul</strong>. Then, Save it.</p>
<pre><font face="Courier New" size="2"><font color="#0000ff">&lt;?</font><font color="#800000">xml </font><font color="#ff0000">version</font><font color="#0000ff">=</font>"<font color="#0000ff">1.0</font>"<font color="#0000ff">?&gt;</font>
<font color="#0000ff">&lt;</font><font color="#800000">overlay </font><font color="#ff0000">id</font><font color="#0000ff">=</font>"<font color="#0000ff">sample</font>"
   <font color="#ff0000">xmlns</font><font color="#0000ff">=</font>"<font color="#0000ff"><u>http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</u></font>"<font color="#0000ff">&gt;</font>
<font color="#0000ff">&lt;</font><font color="#800000">statusbar </font><font color="#ff0000">id</font><font color="#0000ff">=</font>"<font color="#0000ff">status-bar</font>"<font color="#0000ff">&gt;</font>
<font color="#0000ff">&lt;</font><font color="#800000">statusbarpanel </font><font color="#ff0000">id</font><font color="#0000ff">=</font>"<font color="#0000ff">my-panel</font>"
<font color="#ff0000">  label</font><font color="#0000ff">=</font>"<font color="#0000ff">Hello,World</font>"<font color="#0000ff">/&gt;</font>
<font color="#0000ff">&lt;/</font><font color="#800000">statusbar</font><font color="#0000ff">&gt;</font>
<font color="#0000ff">&lt;/</font><font color="#800000">overlay</font><font color="#0000ff">&gt;</font>
 </font></pre>
<h4>Step #7</h4>
<p>Open the file called chrome.manifest (e.g:  C:\extensions\myExtension\chrome.manifest) And Add in this code below:</p>
<pre>
content     sample    chrome/content/
overlay chrome://browser/content/browser.xul chrome://sample/content/sample.xul</pre>
<h4>Step #8 &#8211; Test</h4>
<ol>
<li>Open your Firefox Profile Folder<br />
Note: Do you know where your Firefox Profile Folder is?<br />
If you dont know, Type &#8220;%userprofile%&#8221; in Run. Or go and find the folder same as login name under <strong>Documents and Settings</strong> Folder. then uncheck &#8220;Show Hidden files and Folder&#8221; of Folder Option. (I already told you where Folder Option is. :)) After that, go to <strong>Application Data\Mozilla\Firefox\Profiles</strong> Folder .<br />
Yes. This is your Firefox Profile Folder. You will see the folder called &#8220;extension&#8221;(Sometime, there are some sub folders. eg: kmdxbpyy.default or ujwao9qo.default. Check into them.) I found it under &#8220;<strong>%userprofile%\Application Data\Mozilla\Firefox\Profiles\kmdxbpyy.default\</strong>&#8220;..<br />
<a href="http://kb.mozillazine.org/Profile_folder">More:Profile folder &#8211; MozillaZine</a></li>
<li>Create a folder and give the id of your extension as its name. eg: sample@foo.net</li>
<li>Close Firefox Browser if it&#8217;s opened.</li>
<li>Launch Firefox Browser again. You will see &#8220;Hello, World&#8221; in the Status Bar of Firefox browser.</li>
</ol>
<p>Note: The way of testing is not same as the original article. You may also find the original way in <a href="http://developer.mozilla.org/en/docs/Building_an_Extension">here</a>.</p>
<p>Updated!</p>
<p>Result ~</p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/05/firefox-extension-sample.jpg" alt="Firefox Extension - Sample" /></p>
<p><img src="http://michaelsync.net/wp-content/uploads/2007/05/frefox-extension-hello-world.jpg" alt="frefox-extension-hello-world.jpg" /></p>
<p>Download ~ <a href="http://michaelsync.net/demo/sample@foo.net.zip">http://michaelsync.net/demo/sample@foo.net.zip</a></p>
<p>That&#8217;s all. It&#8217;s easy. isn&#8217;t it? :)</p>
<p>More Info: <a href="http://developer.mozilla.org/en/docs/Extensions">Mozilla Firefox &gt; Extensions</a>
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2006/12/06/8-steps-to-create-your-owned-firefox-extension&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2006/12/06/8-steps-to-create-your-owned-firefox-extension/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>MSFirefox or IE7?</title>
		<link>http://michaelsync.net/2006/11/22/msfirefox-or-ie7</link>
		<comments>http://michaelsync.net/2006/11/22/msfirefox-or-ie7#comments</comments>
		<pubDate>Wed, 22 Nov 2006 10:23:43 +0000</pubDate>
		<dc:creator>Michael Sync</dc:creator>
				<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://michaelsync.net/2006/11/22/msfirefox-or-ie7</guid>
		<description><![CDATA[Did u know that? I came to know a web site called MSFirefox today. I&#8217;m wondering if Microsoft really made that product and this website because there are a lot of things which are very very strange to me. 1....]]></description>
			<content:encoded><![CDATA[<p><strong>Did u know that? </strong></p>
<p>I came to know a web site called <a href="http://www.msfirefox.com/">MSFirefox</a> today.</p>
<p><a href="http://www.msfirefox.com/"><img src="http://michaelsync.net/wp-content/uploads/2006/11/logo.PNG" alt="logo.PNG" /></a></p>
<p>I&#8217;m wondering if Microsoft really made that product and this website because there are a lot of things which are very very strange to me.</p>
<p>1. <strong>Smiling Bill Gates Photo at the left banner.</strong></p>
<p><a href="http://michaelsync.net/wp-content/uploads/2006/11/smiling-bills.PNG" title="smiling-bills.PNG"><img src="http://michaelsync.net/wp-content/uploads/2006/11/smiling-bills.PNG" alt="smiling-bills.PNG" /></a></p>
<p><strong>2.  The one they are giving as download is IE7-WindowsXP-x86-enu.exe </strong></p>
<p>This is the installer for Internet Explorer 7.</p>
<p><strong>3. It&#8217;s not FREE </strong></p>
<p>30$?</p>
<p><strong>4.  The definition of RSS in <a href="http://www.msfirefox.com/firefox-full-features.html">Full Features Page</a> or <a href="http://www.msfirefox.com/microsoft-r-firefox-support/what-is-rss.html">this page</a>.</strong></p>
<p>RSS means &#8230; Arh! ..  Better go and check it out.</p>
<p>If you wanna read more, you may chk their <a href="http://www.msfirefox.com/microsoft-r-firefox-support/index.html">support page</a>.</p>
<p><strong>5. Strange Photo in 4th Feature &#8220;Fast Fun&#8221; which is mentioned in <a href="http://www.msfirefox.com/microsoft-firefox/index.html">Home Page</a>.</strong></p>
<p>That girl from this photo looks very like one of the porn stars from Japan. (but not sure.)</p>
<p><em>Yeah. Maybe there are some more but let me stop here.</em></p>
<p>I just assume that <a href="http://www.msfirefox.com/">this</a> website might be created by someone who hate Microsoft.  Let me know if you guys have any idea about <a href="http://www.msfirefox.com/">this site</a>.</p>
<p>Opps! Almost forget..  <a href="http://www.msfirefox.com/29AIS9DI-20I0AS/msff2007.wmv">Here</a> is a movie from their site..
<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://michaelsync.net/2006/11/22/msfirefox-or-ie7&#038;layout=standard&#038;show_faces=false&#038;width=450&#038;height=25&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px;"></iframe></div>
]]></content:encoded>
			<wfw:commentRss>http://michaelsync.net/2006/11/22/msfirefox-or-ie7/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

