Fix CORS detection code to prevent errors in IE6