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 badges
Add a ment  | 

3 Answers 3

Reset to default 3

IE9 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