IE Specific: Javascript Does Not Execute Replacement on <a>

We run a social sharing button and recently after upgrading to a dynamic javascript inclusion we’ve noticed that many version of Internet Explorer are not running / rendering out script at all. Chrome, Firefox, Safari, iOS, and anything else handle the button just fine.

Because this sits on third party sites which can run a host of scripts [not to mention load time considerations] we’re not able to take advantage of jquery or something else along those lines.

Here’s the code installed on a page:

This in turn will pull up an iFrame in place of the link which connects to our processing server with variables from the link passed over to form the button.

	var lnksNodeList = document.getElementsByTagName("a");
	var lnks =;
	for (var i = 0; i < lnks.length; i++) {		
		lnk = lnks[i]; ...

It doesn’t seem like IE is recognizing the replacement request at all as the output is simply the original, unformated text link.

Any suggestions on where to start?

It looks like you’re trying to convert a NodeList into an Array! (Sorry, the ClippyJS thing has been stuck in my head…)

Unfortunately, IE does not allow you to use Array.prototype.slice with a NodeList:

Normally it wouldn’t be legal to call Thing.prototype.method on anything but an instance of Thing, however browsers have traditionally allowed — and the ECMAScript Third Edition standard requires — a special case for many Array.prototype methods so that they can be called on any native-JavaScript object which is sufficiently like an Array. This means, notably, that they can be used on the arguments object, which looks like an Array but actually isn’t.

However, NodeList and the other collection objects in the DOM are not defined to be native JavaScript objects; they are allowed to be ‘host objects’, which are implemented completely by the browser and not the language. All bets are off for host objects…

[quote]Whether the slice function can be applied successfully to a host object is implementation-dependent.

So Array.prototype.slice may not work for NodeList, and in IE before version 8, indeed, it won’t.

Clearly should have searched around more but that got me on the right path and the team made a simple change to remove the whole which seems to be working fine. We’ll have to benchmark more of course but rendering is at least correct now…