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 example function that does the same job. Unfortunately this function doesn’t work in WebKit (and hence Safari and Chrome) because of a bug in WebKit: they seem to have managed to invert the behaviour of compareBoundaryPoints with END_TO_START and START_TO_END. Tsk. So I’ve modified the Mozilla example to work consistently with all browsers that support Range Continue reading

Converting a JavaScript date object to an Excel date / time serial value

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 of the items of data I needed to submit was the date and time at which the data was submitted. I wanted to post this information as an Excel date / time “serial value”, so that the Web Query could format the date and time within Excel without any further manipulation. This article contains the JavaScript function I created to format a JavaScript date as an Excel date / time serial value.
Continue reading

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 in IE, which seemed to be missing the eval method on the iframe.

Continue reading

Carriage Returns, Line Feeds and Ampersands in IE / Outlook mailto: links

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 email created via a mailto: link, when opening the mailto using Outlook Express (and Outlook).

However, this was causing some problems for users with IE5.0. Turns out there’s a problem in IE 5.0 with this approach. IE 5.0 doesn’t correctly translate these line breaks into Outlook.

Continue reading