简体   繁体   中英

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

下面的行抛出了一个不支持该属性或方法的对象” Windows XP上的IE 8.0.6上的错误。我已经研究了encodeURIComponent方法,却找不到其他遇到此问题的人。这是我的在这里发布,还是一定要其他?谢谢!

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM