James
James

Reputation: 1

EncodeURIComponent throwing "Object doesn't support this property or method" Error (IE 8)

The following line is throwing a Object doesn't support this property or method" Error on IE 8.0.6 on Windows XP. I've looked into the encodeURIComponent method and I've been unable to find anyone else experiancing this. Is this my issue here, or does it have to be something else? Thank you!

request_type = encodeURIComponent(document.getElementById("request_type").value);

Upvotes: 0

Views: 1358

Answers (1)

rav
rav

Reputation: 696

It might actually be complaining about ".value"

Try breaking the code up like this:

var el = document.getElementById("request_type");
var val = el.value;
var encodedVal = encodeURIComponent(val);

If the script dies on the second line, then that means line 1 is trying to get an element that doesn't exist.

Upvotes: 4

Related Questions