What a day! Recently, one of our customers was saying that his site wasn’t working whenever he viewed it in his local net-cafe. This was incredible, to me, as every computer I’ve checked it on has displayed fine.
I finally had an inkling of an idea why this was happening, when I asked him to “click help->about in the browser”, to find out what exact version this was happening in. He said that the browser wasn’t allowing him to access that information.
I understood immediately that it was a security thing. Net-cafes would naturally hate to be infected with the myriad viruses out there, so they tend to belt-up their browsers tighter than the average user.
To make it work, I needed to turn on “Active Scripting” (what IE calls ECMAScript), and let it run safe ActiveX modules.
I began searching through the source of every AJAX library I could think of – Sarissa, JSPan, Sajax, ie7-xml-extras – every single one of them relied on ActiveX.
Surely there must be some XMLHttpRequest library out there that doesn’t rely on ActiveX?
I sat down, and started work on one. It’s Friday, and I’m exhausted after a very long day’s research, so I won’t go too in-depth into it…
There are some problems with the above, which I’ll detail.
First off, the file is a drop-in emulation of the XMLHttpRequest object. I wanted to use the exact same API as every other library on the planet is using.
The short explanation of how it works: the library creates an
<iframe>, populates it with the requested data, then returns the source of that object.
That’s not quite as simple as it sounds. I got 90% of the code working in 10% of my working time today, and spent the next 90% of the day trying, and failing, to solve the other 10%.
As it is, the file works – it should be bloody simple to add it to any library out there. The major problem, though, is white-space.
innerHTML returned by IE is not exactly what it was given, but there is no other way of obtaining it.
Trust me – I spent hours crawling through the MSDN library today (in Firefox, because I had IE set on stun, so the navigation (which is ActiveX-based) wouldn’t work) – there is no other way.
I even tried dynamically creating a
<object> to grab the data from it, but got alerts complaining that this was an ActiveX object!
If anyone out there in blogland has an inkling of an idea how to go forward from here, please do pipe up.