After six hours of randomly changing things to see if it would help, I changed the doctype from html to xhtml ... and the script ran on IE9.
What the hell?!?! I don't even know why that would do it. It was just a random-fingers-crossed change. Six hours ...
... I wish I had gone to college and studied this stuff instead of learning it on the fly!