Why ++[[]][+[]]+[+[]] evaluates to “10″ in JavaScript
This comes from a popular question on Stack Overflow. Given the popularity of the question, the fact that it is now closed and the fact that the highest-ranked answer there is a little imprecise, I’ve decided to write up an explanation here. I should warn you now that I’m going to make reference to the […]
Read More
My Commute
Yesterday I attended the NESTA / Rewired State Make It Local hack day. Myself and five other developers were challenged to create something useful with local data in six hours. My contribution was “My Commute”, a travel planning web site for your daily commute to work. The idea for My Commute was inspired by Paul Hammond’s excellent Minimuni, which is a […]
Read More
Empty XHTML tags and Internet Explorer DOM traversal
Here’s the problem: HTML and XHTML pages containing empty elements with no end tag such as <span /> break JavaScript DOM traversal methods in Internet Explorer 6, 7 and 8, resulting in nodes after such an element showing up in more than one node’s childNodes collection. Consider the following XHTML document: <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML […]
Read More
Range.intersectsNode, Mozilla and WebKit
Today I needed to know whether a Range object (obtained from a selection) intersected with a particular node within an HTML document, which is a relatively common scenario when developing WYSWIYG editors. Mozilla’s implementation of Range used to have a proprietary intersectsNode method, which was ideal. However, they’ve removed this in Gecko 1.9 (and therefore Firefox 3) and provided an […]
Read More
Converting a JavaScript date object to an Excel...
I recently needed to post some data from a web page into a database table. This database table happens to be viewable as a simple html table on a web page. As part of the analysis of the data, the html table of data is inserted into an Excel worksheet as a Web Query. One […]
Read More
JavaScript eval in iframes
In the course of developing a new version of log4javascript, I was adding a command line feature that required the ability to evaluate and execute code in an iframe from within the main window. Fine, I thought, I’ll just call eval on the iframe window object. Which predictably worked fine in Firefox and Opera 8+, but did nothing […]
Read More
Number and size of cookies in Internet Explorer
I’ve been working on an Intranet project which has been attempting some hefty (and perhaps inadvisable) setting and retrieval of cookies via JavaScript. It’s led to some interesting discoveries, and more importantly the discovery of what seems like a bug in IE6. The project is for users with IE6 only.
Read More
Carriage Returns, Line Feeds and Ampersands in IE...
I do quite a lot of work on Intranets, on which the only browser in use is Microsoft Internet Explorer. This often means that IE-specific tricks can be used safely on the Intranet. This specific trick is for using IE with Outlook. I read on MSDN about how to include line breaks in the body of an […]
Read More