<?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>tgreenaway.com &#187; javascript</title>
	<atom:link href="http://tgreenaway.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://tgreenaway.com</link>
	<description>Creatively engineered.</description>
	<lastBuildDate>Sat, 30 May 2009 06:06:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tripping up your JavaScript in IE7</title>
		<link>http://tgreenaway.com/2009/02/tripping-up-your-javascript-in-ie7/</link>
		<comments>http://tgreenaway.com/2009/02/tripping-up-your-javascript-in-ie7/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 03:08:47 +0000</pubDate>
		<dc:creator>TCMG</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tgreenaway.com/?p=254</guid>
		<description><![CDATA[After developing an intensive JavaScript website in Firefox and testing with other browsers, including IE8 in compatibility mode I discovered IE8&#8217;s compatibility mode doesn&#8217;t simulate IE7&#8217;s JS.
Hence a JS bug was bringing all of IE7&#8217;s JS processing to a halt even on the initial page load.
A first step I recommend is temporarily deactivating any JS [...]]]></description>
			<content:encoded><![CDATA[<p>After developing an intensive JavaScript website in Firefox and testing with other browsers, including IE8 in compatibility mode I discovered IE8&#8217;s compatibility mode doesn&#8217;t simulate IE7&#8217;s JS.</p>
<p>Hence a JS bug was bringing all of IE7&#8217;s JS processing to a halt even on the initial page load.</p>
<p>A first step I recommend is temporarily deactivating any JS compressors you may have enabled as pathing problems can crop up from using them and cause issues for IE7.</p>
<p>Beyond that I discovered the major snag resulted in this error from Visual Studio:</p>
<blockquote><p>Expected identifier, string or number</p></blockquote>
<p>Unfortunately that doesn&#8217;t give too much information but I was discovering it in my callback functions within my jQuery. It turns out IE7 has a particular issue with the syntax of JSON:</p>
<pre>
<pre class="brush: javascript;">
$(&quot;.box&quot;).animate({
    height: &quot;100%&quot;,
    opacity: &quot;1.0&quot;,
  }, 600, function() {
    alert(&quot;test!&quot;);
});
</pre>
</pre>
<p>While the above appears to be valid there is a deceptively simple issue that IE7 chokes on. The comma on the end of the third line. While most browsers recognise the empty slot after the opacity variable of the JSON array being passed into the animate function &#8211; IE7 gets really confused and starts complaining about the next semi-colon in your code (in this case part of the callback function).</p>
<p>Just an interesting issue that other browsers don&#8217;t care about but IE7 is really bamboozled by <img src='http://tgreenaway.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tgreenaway.com/2009/02/tripping-up-your-javascript-in-ie7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Javascript</title>
		<link>http://tgreenaway.com/2008/08/debugging-javascript/</link>
		<comments>http://tgreenaway.com/2008/08/debugging-javascript/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 15:39:08 +0000</pubDate>
		<dc:creator>TCMG</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tgreenaway.com/?p=49</guid>
		<description><![CDATA[So far my experience with Javascript has not required too much dealing with its raw form. I&#8217;m a big fan of the jQuery library and I&#8217;ve heard described as a swiss army knife for Javascript. I think that&#8217;s an understatement though, it goes beyond just being a toolset. I believe it is a framework in [...]]]></description>
			<content:encoded><![CDATA[<p>So far my experience with Javascript has not required too much dealing with its raw form. I&#8217;m a big fan of the jQuery library and I&#8217;ve heard described as a swiss army knife for Javascript. I think that&#8217;s an understatement though, it goes beyond just being a toolset. I believe it is a framework in its own right. And in fact, it pushes all your Javascript code into a more structured form.</p>
<p>I recently fixed a problem with a website that was developed by someone using raw Javascript. Basically it failed to work in IE. The underlying problem was that IE doesn&#8217;t recognise the visual text of a drop down select box in the DOM of the page as the &#8216;value&#8217; of the element in the drop down select box.</p>
<p>So if you selected &#8220;5pm&#8221; from the box, the Javascript can&#8217;t be:</p>
<pre>
<pre class="brush: jscript;">foo = frm.select[bar].value;</pre>
</pre>
<p>It has to be:</p>
<pre>
<pre class="brush: jscript;">foo = frm.select[bar].text;</pre>
</pre>
<p>If you want it to work across all the browsers. In jQuery, you would never even write code like the above. You&#8217;d be using the CSS selectors:</p>
<pre>
<pre class="brush: jscript;">$(&quot;#date_select&quot;).text();</pre>
</pre>
<p>The above would find the element with id &#8216;date_select&#8217; and extract its text. Why the dollar sign? It tells Javascript we&#8217;re dealing with the jQuery library.</p>
<p>So you see, jQuery just <em>looks </em>different to raw Javascript most of the time. For example, take a load of this raw Javascript:</p>
<pre>
<pre class="brush: jscript;">
document.getElementById(&amp;quot;x20&amp;quot;).style.display='none';
document.getElementById(&amp;quot;x21&amp;quot;).style.display='none';
document.getElementById(&amp;quot;x22&amp;quot;).style.display='none';

var d = frm.Dates;
var dval = d.options[d.selectedIndex].text;
var idx;

for (x=frm.Times.length;x&amp;gt;0;x=x-1)
{
        frm.Times.remove(x);
}
</pre>
</pre>
<p>Ugh, messy. jQuery steps away from the &#8216;document&#8217; rubbish by using the CSS selectors mentioned previously. And the for loop? jQuery provides you with functions to iterate throughout CSS selected elements:</p>
<pre>
<pre class="brush: jscript;">
$(&quot;#times_list li&quot;).each(function () {
  this.remove()
}
</pre>
</pre>
<p>Where &#8216;this&#8217; is one of the CSS selector&#8217;s matched elements, iterated by the &#8216;each&#8217; function.</p>
]]></content:encoded>
			<wfw:commentRss>http://tgreenaway.com/2008/08/debugging-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
