Wednesday, 14 May 2008

FireFox double page load

OK... to anyone who's implementing a page counter.... if you find that the counter is doubling up when a request from FireFox (under OSX/Linux/doze) it's because the browser is loading the page twice. It's also due to how the W3C spec is written... and the behavior is entirely correct (if not a bit annoying).

If a browser find an IMG with an empty SRC tag then it should reload the page once more to check. I had an empty IMG SRC which was then dynamically assigned to with JavaScript.

To resolve the problem I just put a temporary image in place... which will never be seen because the containing div is hidden until the Javascript makes it visible again... at which point the correct image will be assigned to it.


Work around for Internet Explorer when dynamically changing Select Option

OK, so quite a common thing to do is update the items in a multiple select box with options sent from the server through some javascript.

And it's very simple.. you just get your response and stick it into the select box with using innerHTML on the select box. Unless you're using IE that is!

IE has a bug where is will remove the first OPTION when using innerHTML. It's only been there since 1999, so I'm sure they'll fix it soon! :P In the mean time check out this blog entry:

Which has good info, or return XML from your server and parse it in the Javascript creating new Options as you go. This is how I did it, adapted slightly from 'Learning Javascript'.

var opsnodes = xmlhttp.responseXML.getElementsByTagName('op');
for(var i = 0; i < opsnodes.length; i++){
var name = value = null;
for(var j = 0; j < opsnodes[i].childNodes.length; j++){
var elem = opsnodes[i].childNodes[j].nodeName;
var val = opsnodes[i].childNodes[j].firstChild.nodeValue;
if (elem == 'value'){
value = val;
name = val;
}//end for j
sel.options[i] = new Option(name,value);
}//end for i
alert('Sorry there was an error');

where sel is the select box.

Interesting Sign

So, this was shown during the safety video on a bus near Oslo.... anyone wanna get in front of the bus to get the fire extinguisher? :-)

Tuesday, 13 May 2008

Bebo Application Development - Why no Javascript!!

So, I've built a Facebook application which uses the Facebook Javascript Sandbox. I mean, this is Web 2.0... of course it uses Javascript!

So, Bebo have (for a while now I guess) supposedly been code compatible with Facebook... however this seems to just be the FBML (or SNML as it now seems to be called). This is great.. but the lack of any form of JS support reduces the impact of being code compatible with Facebook.

I'll have to either we write the application to be rather static.. or rewrite it to not use any FBML and put it all in an iframe.


Wednesday, 7 May 2008

Snow in London

It's hard to believe it at the moment (given our stunning sunshine!), but this was the covering that London received not to long ago:

Neutral Density Photography

This image was shot in Cornwall using a Neutral Density 4 filter. Some slight dirt on the actual filter made it a bit messy, but I think this adds to the effect.