Tostring Does Not Work In Ie
Solution 1:
Actually the comments above are not correct. Although you may not be able to override default prototype methods on elements, you CAN do it for your own types. The problem is that toString is not returned as a key in the code snippet:
for (var keyin o) arg[key] = o[key];
if you add the following, things will work as expected:
if (o.toString !== Object.prototype.toString) {
arg.toString = o.toString
}
Solution 2:
Ok I see your issue now.
In all older version of IE (previous to 9) the javascript engine does not let you modify an element's prototype functions.
So the default toString()
of an object is [object Object]
You might have to think of a different approach to your code for older versions of IE.
See article here: http://blog.motane.lu/2007/09/20/elementprototype-in-ie/
Final answer from comments below:
.toString
is already a predefined function in the prototype of all objects, and it cannot be overridden in IE. Try using a different function name.
Solution 3:
Actually you can! You just gotta move the toString outside
Person.prototype.toString = function() { returnthis.name; }
Further info check this other post
Post a Comment for "Tostring Does Not Work In Ie"