<?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>nerd. &#187; Web Design</title>
	<atom:link href="http://nerd.steveferson.com/category/web/webdesign/feed/" rel="self" type="application/rss+xml" />
	<link>http://nerd.steveferson.com</link>
	<description>One nerd's struggle against the beast that is technology</description>
	<lastBuildDate>Tue, 10 Jan 2012 13:15:45 +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>Solved: IE event &#8211; &#8220;this.parentNode.parentNode is null or not an object&#8221;</title>
		<link>http://nerd.steveferson.com/2008/08/09/solved-ie-event-thisparentnodeparentnode-is-null-or-not-an-object/</link>
		<comments>http://nerd.steveferson.com/2008/08/09/solved-ie-event-thisparentnodeparentnode-is-null-or-not-an-object/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 13:25:06 +0000</pubDate>
		<dc:creator>nerd.</dc:creator>
				<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Mozilla Firefox]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[addEventListener]]></category>
		<category><![CDATA[attachEvent]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://nerd.steveferson.com/?p=122</guid>
		<description><![CDATA[&#8230; it bloody-well is! This post was very nearly &#8220;Things that piss me off 5: Internet Explorer&#8221; (that one may yet come) but I thought a more descriptive title would help more people struggling with the same problem to find it. Anyway: background.  I am writing a new feature for a Content Management System to [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230; it bloody-well is! This post was very nearly &#8220;<a title="Niggles @ nerd." href="http://nerd.steveferson.com/category/inside-nerd/niggles-inside-nerd/">Things that piss me off</a> 5: Internet Explorer&#8221; (that one may yet come) but I thought a more descriptive title would help more people struggling with the same problem to find it.</p>
<p>Anyway: background.  I am writing a new feature for a Content Management System to allow users to upload files. With a simple bit of javascript I added a &#8220;+&#8221; button to allow them to add new rows to the form, allowing them to upload multiple files. It looks a bit like this:</p>
<div id="attachment_125" class="wp-caption aligncenter" style="width: 510px"><a href="http://nerd.steveferson.com/wp-content/uploads/2008/08/upload-images-screenshot1.png"><img class="size-full wp-image-125" title="How can IE balls up something so simple?" src="http://nerd.steveferson.com/wp-content/uploads/2008/08/upload-images-screenshot1.png" alt="Screenshot of Upload Images feature" width="500" height="166" /></a><p class="wp-caption-text">Screenshot of Upload Images feature</p></div>
<p>Anyway, it would obviously be nice to allow the user to remove a row if they&#8217;ve added one or two too many. The obvious solution seems to be to add a &#8220;-&#8221;  button beside each. Easy, right?</p>
<p>Unfortunately Internet Explorer, as per usual, ballses everything up. Because each &#8211; button is created dynamically I have to add an EventListener using JavaScript code. No problem so far. That event listener is a simple, one-line:</p>
<p><code>this.parentNode.parentNode.removeChild(this.parentNode);</code></p>
<div style="float: right; margin: 5px;"><script type="text/javascript"><!--
google_ad_client = "pub-5035384023750057";
/* nerd., inContent Square */
google_ad_slot = "2297896054";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>As each row (the label, field itself (including button) and &#8220;-&#8221; link) is inside a div, the above code should remove that div and therefore remove the row. And it does&#8230; in Firefox. Try it in Internet Explorer and you get a message telling you &#8220;Error: &#8216;this.parentNode.parentNode&#8217; is null or not an object&#8221;.</p>
<h3><strong>Whhhaaa?!</strong></h3>
<p>Don&#8217;t you just hate when you can easily find something your code claims it can&#8217;t? Am I the only one who screams &#8220;It&#8217;s right f**king there!!&#8221; at my monitor? In this case, the problem seems to boil down to IE&#8217;s supid, proprietary, fucked up way of attaching Event listeners. When you use <span style="text-decoration: line-through;">Mozillas</span> the <a title="Document Object Model Events - Registration" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration">W3C standard addEventListener</a> method to attach a listener to an event, &#8220;this&#8221; in the event handler refers to the object which the event is called on. Obvious, yes?  However when you use IE&#8217;s attachEvent instead, IE doesn&#8217;t seem to act in the same way. <a title="attachEvent - about.com" href="http://javascript.about.com/library/bldom20.htm">Apparently</a>, instead, IE sets &#8220;this&#8221; in an event handler to the window object instead of the calling/event object! Another good job from Micro$oft!</p>
<p>Apparently it&#8217;s <a title="Fixing IE's .attachEvent(..) failures - Incoherent Babble" href="http://blog.stchur.com/2006/10/12/fixing-ies-attachevent-failures/">can be overcome</a>, but that involves a <em>lot </em>of code and I refuse in principle to do that much inelegant hacking for something so simple. It&#8217;s much easier (and principled) to do this:</p>
<div id="attachment_128" class="wp-caption aligncenter" style="width: 418px"><a href="http://nerd.steveferson.com/wp-content/uploads/2008/08/ie-attachevent-error.jpg"><img class="size-full wp-image-128" title="Satisfying!" src="http://nerd.steveferson.com/wp-content/uploads/2008/08/ie-attachevent-error.jpg" alt="IE error message: &quot;Sorry, your browser doesn't support this function. This is probably because you're using Internet Explorer. www.getFirefox.com&quot;" width="408" height="182" /></a><p class="wp-caption-text">Not really a long-term solution, but bloody satisfying nonetheless.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://nerd.steveferson.com/2008/08/09/solved-ie-event-thisparentnodeparentnode-is-null-or-not-an-object/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Big PHP Niggle</title>
		<link>http://nerd.steveferson.com/2008/06/20/big-php-niggle/</link>
		<comments>http://nerd.steveferson.com/2008/06/20/big-php-niggle/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 16:31:53 +0000</pubDate>
		<dc:creator>nerd.</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Niggles]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://nerd.steveferson.com/?p=85</guid>
		<description><![CDATA[I need a quick bitch. I love PHP. It&#8217;s everywhere. All my sites are written in it. My CMS is written in it. My blog engines, WordPress and b2evolution, are written in it. It&#8217;s free. It runs on any platform. Hosts all support it. With PHP 5 they&#8217;ve even done a lot of work on [...]]]></description>
			<content:encoded><![CDATA[<p>I need a quick bitch.</p>
<p>I love <a title="PHP: Hypertext Preprocessor" href="http://www.php.net/">PHP</a>. It&#8217;s everywhere. All my sites are written in it. My CMS is written in it. My blog engines, <a title="WordPress › Blog Tool and Weblog Platform" href="http://www.wordpress.org/">WordPress</a> and <a title="b2evolution: More than a blog! — Blog+Photo+CMS software" href="http://b2evolution.net/">b2evolution</a>, are written in it. It&#8217;s free. It runs on any platform. Hosts all support it. With PHP 5 they&#8217;ve even done a lot of work on PHP4&#8242;s main downfall &#8211; lack of OOP support.</p>
<p>One thing really pisses me off though &#8211; it&#8217;s totally inconsistent.  Consider these two functions:</p>
<ol>
<li><a title="PHP: strstr - Manual" href="http://uk.php.net/manual/en/function.strstr.php">strstr</a> — Find first occurrence of a string</li>
<li><a title="PHP: in_array - Manual" href="http://uk.php.net/manual/en/function.in-array.php">in_array</a> — Checks if a value exists in an array</li>
</ol>
<p>Take a close look. See the signatures?</p>
<p><code> string strstr  ( string $haystack  , mixed $needle  [, bool $before_needle  ] )</code><br />
<code> bool in_array  ( mixed $needle  , array $haystack  [, bool $strict  ] )</code></p>
<p>In in_array the first parameter is what you&#8217;re looking for and the second is what you&#8217;re looking in (more or less consistent with <a title="PHP: preg_match - Manual" href="http://uk.php.net/manual/en/function.preg-match.php">preg_match</a>).  In strstr (and its derivatives) this order is reversed. Who on Earth let that slip through? I&#8217;m yet to find a free text editor that will tell you which parameters a given function expects (Dreamweaver does a decent job but it&#8217;s bloody expensive for a text editor!) the way Visual Studio does for C#, which I use a lot in work.  Given that situation, you&#8217;d expect consistency in this sort of thing.  Apparently not so. Instead, every time I want to use one of these functions I have to do a quick Google to bring me to the PHP manual page to tell me which order the parameters come in.</p>
<p>Of course they can&#8217;t even fix that without breaking backwards compatibility either, so we&#8217;re probably stuck with it.  Bloody marvellous!</p>
]]></content:encoded>
			<wfw:commentRss>http://nerd.steveferson.com/2008/06/20/big-php-niggle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>I Can Has Vista Sidebar Gadget?</title>
		<link>http://nerd.steveferson.com/2008/04/28/i-can-has-vista-sidebar-gadget/</link>
		<comments>http://nerd.steveferson.com/2008/04/28/i-can-has-vista-sidebar-gadget/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 23:32:39 +0000</pubDate>
		<dc:creator>nerd.</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[gadget]]></category>
		<category><![CDATA[jokes]]></category>
		<category><![CDATA[lolcats]]></category>
		<category><![CDATA[sidebar]]></category>
		<category><![CDATA[vista]]></category>

		<guid isPermaLink="false">http://nerd.steveferson.com/?p=72</guid>
		<description><![CDATA[O hai! I hart lolcatz. I hart lolcatz so much dat wun dai I thoughted &#8220;I can has lolcatz wen I makes teh pooter turn on?&#8221; So I maded a Vista gadjit an now I has new lolcatz every dai. If u hart lolcatz liek mee an wants lolcatz in ur pooter makin u laff, [...]]]></description>
			<content:encoded><![CDATA[<p>O hai!</p>
<p>I hart <a title="Lolcats 'n' Funny Pictures - I Can Has Cheezburger?" href="http://icanhascheezburger.com/">lolcatz</a>.</p>
<p>I hart lolcatz so much dat wun dai I thoughted &#8220;I can has lolcatz wen I makes teh pooter turn on?&#8221;  So I maded a <a title="Lolcats Vista Sidebar Gadget" href="http://nerd.steveferson.com/lolcats-vista-gadget/">Vista gadjit</a> an now I has new lolcatz every dai.</p>
<p>If u hart lolcatz liek mee an wants lolcatz in ur pooter makin u laff, downlodes <a title="Lolcats Vista Sidebar Gadget" href="http://nerd.steveferson.com/lolcats-vista-gadget/">mah gadjit</a>. I has tested it 4 liek rly long time. It rly works, srsly. An evry1 needses moar lolcatz.</p>
<p>Kthxbai.</p>
<p><span id="more-72"></span></p>
<p>* If you think that was hard to read, you should see the <a title="Genesis 1 - LOLCat Bible Translation Project" href="http://www.lolcatbible.com/index.php?title=Genesis_1">lolcat bible</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nerd.steveferson.com/2008/04/28/i-can-has-vista-sidebar-gadget/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ACT &#8211; SessionID and Login Problems With ASP .NET 2.0</title>
		<link>http://nerd.steveferson.com/2007/09/14/act-sessionid-and-login-problems-with-asp-net-20/</link>
		<comments>http://nerd.steveferson.com/2007/09/14/act-sessionid-and-login-problems-with-asp-net-20/#comments</comments>
		<pubDate>Fri, 14 Sep 2007 09:38:16 +0000</pubDate>
		<dc:creator>nerd.</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://nerd.steveferson.com/2007/09/14/act-sessionid-and-login-problems-with-asp-net-20/</guid>
		<description><![CDATA[I recently encountered a problem with Microsoft&#8217;s ACT (part of Visual Studio 2003) when testing a web service by emulating a browser-based client. For posterity&#8217;s sake, here&#8217;s an overview of the problem and, more importantly, the solution. Background Using Application Center Test (ACT) to help automate performance testing designed to compare the performance of a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently encountered a problem with Microsoft&#8217;s ACT (part of Visual Studio 2003) when testing a web service by emulating a browser-based client.  For posterity&#8217;s sake, here&#8217;s an overview of the problem and, more importantly, the solution.</p>
<p><strong>Background</strong><br />
Using Application Center Test (ACT) to help automate performance testing designed to compare the performance of a web service running on ASP .NET 1.1 with ASP .NET 2.0.</p>
<p><strong>Problem</strong><br />
Originally .NET 2.0 seemed to be performing many times better than .NET 1.1, but it was soon discovered that when running .NET 2.0, ATC was receiving a lot of 302 errors on 2.0 which it wasnâ€™t on 1.0.  On further investigation the Web Service wasnâ€™t actually making all the correct database calls and on installing HTTP Monitor, it became apparent that the login wasnâ€™t working.  When I recorded the test using Internet Explorer 7, the HTTP requests worked as expected, however when ATC repeated them it was not returning the ASP.NET_SessionID.</p>
<p><span id="more-27"></span><strong>Cause</strong><br />
In .NET 2.0 Microsoft introduced a new cookie property as a security measure: HttpOnly.  This was appended to the cookie, which apparently confused Application Center Test.  Normaly the cookie is only sent to clients that can understand it, but ACT was pretending to be IE7 so it was sent the new property with the cookie.  As it couldnâ€™t understand it, it seemingly discarded the whole cookie meaning the SessionID wasnâ€™t sent back on future requests.  As a result, every time ACT tried to fetch a URI, it was getting a 302, redirecting it to the login page because the server didnâ€™t know it had logged in.</p>
<p><strong>Solution</strong><br />
In Global.asax, overwrite the Session_Start method as follows.<br />
<code style="white-space: pre">&lt;script runat="server"&gt;<br />
void Session_Start(object sender, EventArgs e) {<br />
if(Response.Cookies.Count &gt; 0)<br />
   foreach(string s in Response.Cookies.AllKeys)<br />
      if(s == System.Web.Security.FormsAuthentication.FormsCookieName ||<br />
s.ToLower().Equals("asp.net_sessionid") )<br />
         Response.Cookies[s].HttpOnly = false;<br />
}<br />
&lt;/script&gt;</code></p>
<p>As it turns out though, the specific web service I was dealing with did not use the SessionID to track sessions and used another cookie variable instead.  To deal with this, I also added the following code to remove the HttpOnly attribute from all cookies (NB this could be considered a security risk as all cookies will be exposed to client-side scripts, however in this instance it was utilised only for internal testing ):<br />
<code style="white-space: pre">void Application_EndRequest(object sender, EventArgs e) {<br />
   if (Response.Cookies.Count &gt; 0) {<br />
      foreach (string s in Response.Cookies.AllKeys) {<br />
         Response.Cookies[s].HttpOnly = false;<br />
      }<br />
   }<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://nerd.steveferson.com/2007/09/14/act-sessionid-and-login-problems-with-asp-net-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

