admin管理员组文章数量:1406976
I am trying to built a websocket application in IE9 but I have the following Javascript error:
IE9 Console:
SCRIPT438: Object doesn't support property or method 'map'
websock.js, line 211 character 5
websock.js function:
function send_string(str) {
//Util.Debug(">> send_string: " + str);
api.send(str.split('').map(
function (chr) { return chr.charCodeAt(0); } ) );
}
Also in IE9 console str = the text I entered
. and if I try to split it first then I get the correct array of the string but still map is not working.
For example if I try to send "text":
str.split("") = ['t','e','x','t']
And I found this in the console. But unfortunately .map is not working. Any suggestions?
PS:
I tried to change the w3school code this link:
document.write(str.split("").map(
function (chr) { return chr.charCodeAt(0); } ) + "<br />");
And map is working here with the desirable result using IE9!
I am trying to built a websocket application in IE9 but I have the following Javascript error:
IE9 Console:
SCRIPT438: Object doesn't support property or method 'map'
websock.js, line 211 character 5
websock.js function:
function send_string(str) {
//Util.Debug(">> send_string: " + str);
api.send(str.split('').map(
function (chr) { return chr.charCodeAt(0); } ) );
}
Also in IE9 console str = the text I entered
. and if I try to split it first then I get the correct array of the string but still map is not working.
For example if I try to send "text":
str.split("") = ['t','e','x','t']
And I found this in the console. But unfortunately .map is not working. Any suggestions?
PS:
I tried to change the w3school code this link:
document.write(str.split("").map(
function (chr) { return chr.charCodeAt(0); } ) + "<br />");
And map is working here with the desirable result using IE9!
Share Improve this question edited Feb 14, 2012 at 8:30 glarkou asked Feb 14, 2012 at 8:21 glarkouglarkou 7,10112 gold badges69 silver badges122 bronze badges3 Answers
Reset to default 3IE9 supports map, but most possibly your html page is rendered in quirks mode, that's why. Try adding a doctype, and see if that solves the problem.
According to the ES5 patibility table, IE9 does support Array#map
. Visit http://kangax.github./es5-pat-table/ and look in the “This Browser” column.
Make sure the browser is in IE9 mode.
FF implements map:
Array.prototype.hasOwnProperty('map') // true
IE doesn't implement map:
Array.prototype.hasOwnProperty('map') // false
Sorry, it seems you'll have to code your own map
function.
本文标签: javascriptArraymap not working in IE9Stack Overflow
版权声明:本文标题:javascript - Array.map not working in IE9 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745047258a2639442.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论