views:

361

answers:

3

Safari's XMLHttpRequest's send() method supports a File argument. Firefox does not (yet).

How can I check if this is supported? In Firefox, it will just behave as if an empty string was passed.

I'm trying to avoid doing browser version detection.

Edit: FF 3.6 does seem to support it, but the question is still relevant for older versions or other browsers.

+2  A: 

It's possible that if the File object can be created, than send supports it. In Gecko (firefox,) that will be true (File and the send's File compatibility were both released in 1.9 according to MDC)

robert
in other words, `if (typeof File === "object") { … }`
Sidnicious
A: 

Could plain old browser sniffing not help? jQuery.support could possibly be enough?

ChrisR
"I'm trying to avoid doing browser version detection." Besides, which test in jQuery.support tests for this.
Jaka Jančar
A: 

You should try using Function.length.

EDIT

This solution won't work as the File isn't passed as an additional argument, as pointed out by rnicholson.

ML--
I don't understand how this would help. (new window.XMLHttpRequest).send.length would return 1 in both browsers, would they not?
rnicholson
Indeed, my fault. I just assumed 'File' would be an additional argument. Should I delete the answer?
ML--