How to solve indexOf javascript problem in internet Explorer?
- Sunday, March 13, 2011, 13:20
- How-to, Javascript
- 1 comment
indexOf is not supported by dump web browser internet explorer.
To solve this we need to add following code in our javascript file.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (elt /*, from*/) { var len = this.length >>> 0; var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0) from += len; for (; from < len; from++) { if (from in this && this[from] === elt) return from; } return -1; }; } |
About the Author
One Comment on “How to solve indexOf javascript problem in internet Explorer?”
Write a Comment
Gravatars are small images that can show your personality. You can get your gravatar for free today!
Thanks a lot. I was searching this from the very beginning.