<?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>Tudor Barbu&#039;s professional blog &#187; internet explorer</title>
	<atom:link href="http://blog.motane.lu/tag/internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.motane.lu</link>
	<description>Ramblings about software development</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:38:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Internet Explorer and the pjpeg MIME type</title>
		<link>http://blog.motane.lu/2009/08/28/internet-explorer-and-the-pjpeg-mime-type/</link>
		<comments>http://blog.motane.lu/2009/08/28/internet-explorer-and-the-pjpeg-mime-type/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 12:32:13 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[mime types]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=979</guid>
		<description><![CDATA[Did I mention that I hate Internet Explorer? Well, I do. I think that the web would be a much better place without Internet Explorer. Any Internet Explorer. Today I&#8217;ve ran across another strange IE bug. When uploading a JPEG file, instead of the usual image/jpeg MIME as defined in RFC 1341, if the file [...]]]></description>
			<content:encoded><![CDATA[<p> <img src="http://blog.motane.lu/wp-content/uploads/2009/08/stop_ie.jpg" alt="stop_ie" title="stop_ie" width="247" height="227" class="alignleft size-full wp-image-980" /> Did I mention that I hate Internet Explorer? Well, I do. I think that the web would be a much better place without Internet Explorer. Any Internet Explorer. </p>
<p>Today I&#8217;ve ran across another strange IE bug. When uploading a JPEG file, instead of the usual <strong>image/jpeg</strong> <acronym title="Multipurpose Internet Mail Extensions">MIME</acronym> as defined in <a href="http://tools.ietf.org/html/rfc1341" class="outgoing" title="RFC 1341 on IETF's site">RFC 1341</a>, if the file is a <a href="http://www.faqs.org/faqs/jpeg-faq/part1/section-11.html" title="What is a progressive JPEG article on FAQs.org">progressive jpeg</a>, then Internet Explorer sends a <a href="http://www.iana.org/assignments/media-types/image/" title="Image Media Types on IANA" class="outgoing">non standard MIME</a> of <strong>image/pjpeg</strong>, which sucks, isn&#8217;t documented and breaks validation logic.  </p>
<p>And since my code looked something like:</p>
<pre class="brush: python; title: ; notranslate">
# check mime type
mime, type = image.content_type.split( '/' )
if not ( mime == 'image' and type in ['jpeg', 'gif', 'png'] ):
    return False
</pre>
<p>&#8230;in it, well&#8230;you can imagine!  So, if you *ever* check the MIME type of a file, remember that IE sometimes sends a image/pjpeg MIME.</p>
<blockquote><p>Just remember: No IE / No headaches</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2009/08/28/internet-explorer-and-the-pjpeg-mime-type/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Element.prototype in IE</title>
		<link>http://blog.motane.lu/2007/09/20/elementprototype-in-ie/</link>
		<comments>http://blog.motane.lu/2007/09/20/elementprototype-in-ie/#comments</comments>
		<pubDate>Thu, 20 Sep 2007 21:24:06 +0000</pubDate>
		<dc:creator>Tudor</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cross-browser]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.motane.lu/?p=250</guid>
		<description><![CDATA[Some time ago, I needed to find out if a DOM element is a descendant of another. A simple and elegant way to accomplish this is: &#8230;and afterwards&#8230; Cool, isn&#8217;t it? Element.prototype in IE This kind of approach to js apps works perfect in all modern browsers. But not in &#8220;that browser&#8221;. Not in the [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I needed to find out if a DOM element is a descendant of another. A simple and elegant way to accomplish this is:</p>
<pre class="brush: jscript; title: ; notranslate">
/**
 *
 * @param mixed granpa
 *
 */
Element.prototype.isDescendantOf = function( granpa ) {
	if ( typeof( granpa ) == 'string' ) {
		granpa = document.getElementById( granpa );
	}
	if ( !granpa ) {
		return false;
	}
	child = this;
	do {
		if (child == granpa ) {
			return true;
		}
		child = child.parentNode;
	}
	while ( child );
	return false;
}
</pre>
<p>&#8230;and afterwards&#8230;</p>
<pre class="brush: jscript; title: ; notranslate">
var foo = document.getElementById( 'foo' );
var bar = document.getElementById( 'bar' );
if ( foo.isDescendantOf( bar ) ) {
	/* whatever */
}
</pre>
<p>Cool, isn&#8217;t it?<span id="more-250"></span></p>
<h2><span>Element.prototype in IE</span></h2>
<p>This kind of approach to js apps works perfect in all modern browsers. But not in &#8220;that browser&#8221;. Not in the browser of the many. Because Microsoft doesn&#8217;t allow adding custom methods to the &#8220;Element&#8221; object. Of course, I&#8217;ve tried to use &#8220;Object&#8221; instead of &#8220;Element&#8221;, but this doesn&#8217;t work either &#8211; contrary to the ECMA specifications. In other words, it simply sucks.</p>
<p>But after some googling around, I`ve reach deep into the realm of darkness, the MSDN. And there I&#8217;ve read about IE behaviors, a strange mixture of JScript and XML stored in a HTC file. So I&#8217;ve decided to make one last attempt to get the script working, before smashing my forehead into the keyboard. First of all, an Element object is needed. So I&#8217;ve added these lines to my js file.</p>
<pre class="brush: jscript; title: ; notranslate">
if ( !window.Element ) {
	Element = function() {};
}
</pre>
<p>After that, I&#8217;ve started writing the HTC file. It looked like:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;PUBLIC:COMPONENT&gt;
	&lt;PUBLIC:METHOD NAME=&quot;isDescendantOf&quot; INTERNALNAME=&quot;_isDescendantOf&quot; /&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
			var element = new Element;
			_isDescendantOf = element.isDescendantOf;
		&lt;/script&gt;
&lt;/PUBLIC:COMPONENT&gt;
</pre>
<p>Now this behaviour must be added to all elements if the browser is Internet Explorer. Time to use some simple conditional comments and the CSS universal selector:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!--[if IE]&gt;
&lt;style type=&quot;text/css&quot;&gt;
* { behavior: url(ie_fix.htc) }
&lt;/style&gt;
&lt;![endif]--&gt;
</pre>
<p>And it worked. Eurika. You can download the gzipped example here. Behaviours are not supported by the wine emulated versions of Internet Explorer, so this must be tested on Microsoft Windows ®.</p>
<h2><span>Prototype&#8217;s (the framework) $ function</span></h2>
<p>I consider prototype to be one of best javascript frameworks ever. Yes, I know there are other smaller, less bloated, better documented frameworks out there, but for me, prototype does the job to well to even consider switching.</p>
<p>Using prototype is another way to add custom methods to the Element object. Declare your methods as elements of a javascript hashtable (an array) and then call Element.addMethods().</p>
<pre class="brush: jscript; title: ; notranslate">
var methods = {
	isDescendantOf: function( granpa ) {
		if ( typeof( granpa ) == 'string' ) {
			granpa = document.getElementById( granpa );
		}
		if ( !granpa ) {
			return false;
		}
		child = this;
		do {
			if ( child == granpa ) {
				return true;
			}
			child = child.parentNode;
		}
		while ( child );
		return false;
	}
}
Element.addMethods( methods );
</pre>
<p>Please note that the custom methods will only be available on nodes retrieved by prototype&#8217;s $() function, and not on those retrieved by good old fashioned document.getElementById(). That&#8217;s how prototype works.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.motane.lu/2007/09/20/elementprototype-in-ie/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

