IE6 error

I’ve been trying for hours and I can’t figure out why IE6 is throwing an derror on the following line of code.

var parts = rgbString.match(/^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$/);

This is the function:

function rgbToHex(rgbString)
		var parts = rgbString.match(/^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$/);

		//delete (parts[0]);
		for (var i = 1; i <= 3; ++i) {
			parts[i] = parseInt(parts[i]).toString(16);
			if (parts[i].length == 1) parts[i] = '0' + parts[i];
		hexString = '#'+parts.join('');
		return hexString;

And this is the error:
‘null’ is null or not an object

I don’t know what the IE error is- what are you using for input?
It looks like it is not in the form of an rgb triplet.

The function doesn’t work correctly, however, even where it doesn’t make an error.
/* returned value: (String)

The first index (0) of a non-global match is eveything that matched.

I’m using jquery and set $(this).css(‘backgroundColor’) as input. The function works fine if delete(parts[0]) is uncommented. Not sure why I have it commented in the original post…

alert ($(this).css(‘backgroundColor’)) in IE6- chances are it is not returning the rgb.

You are exactly right :). I was calling my rgbtohex function incorrectly in several places and it was getting passed the null value.

I really shouldn’t have assumed the IE error message was incorrect…it pretty much said exactly what the problem was.