1

Possible Duplicate:
How to fix Array indexOf() in JavaScript for IE browsers
No support for indexOf in IE 8?

I'm trying to make a pacman game and everything was going fine until IE came along.

I'm using the astar code from this website: http://www.briangrinstead.com/blog/astar-search-algorithm-in-javascript

For some reason, it works fine on all the other browers except IE where I get this error msg every single time.

SCRIPT438: Object doesn't support property or method 'indexOf'
graph.js, line 112 character 9

This is how I've gone about calling the function.

var graph = new Graph(MazeMap);
var start = graph.nodes[rows][columns];
var end = graph.nodes[targetRow][targetColumn];
var result = astar.search(graph.nodes, start, end);
Community
  • 1
  • 1
Danny Lee
  • 11
  • 1
  • 3
    Try adding an implementation for the `indexOf` function to the String prototype before including "graph.js" – higuaro Oct 19 '12 at 03:33
  • 4
    Might help to show whats on line 122 of graph.js.... – Hamish Oct 19 '12 at 03:34
  • this is what is on line 122 this.sinkDown(this.content.indexOf(node)); frankly speaking I am still kinda loss at how the code this guy used for his a* algorithm works. – Danny Lee Oct 19 '12 at 03:43
  • Ok so IE doesn't support use of .indexOf(), and from this link http://stackoverflow.com/questions/1744310/how-to-fix-array-indexof-in-javascript-for-ie-browsers I see that there is a way to go round it, but what exactly should I use to replace .indexOf()? – Danny Lee Oct 19 '12 at 03:54
  • 1
    Older versions of IE do not support `.indexOf` on arrays (while other browsers in "contemporary" versions have for some time). Use a shim script like https://github.com/aFarkas/webshim to paper over this problem (and others). – Jared Farrish Oct 19 '12 at 03:56
  • Demos of webshim Array polyfills: http://afarkas.github.com/webshim/demos/demos/es5.html Get use to "IE sank my battleship" complaints. It's a common gripe, although we hold out hope it is improving overall. – Jared Farrish Oct 19 '12 at 03:59
  • The error is actually from [*graph.js*](https://raw.github.com/bgrins/javascript-astar/master/graph.js). – RobG Oct 19 '12 at 04:15
  • okay found a solution posted on another thread http://stackoverflow.com/questions/9768574/no-support-for-indexof-in-ie-8?lq=1 Thanks for all the help guys ^^ – Danny Lee Oct 19 '12 at 04:29
  • +1 for `everything was going fine until IE came along` love it :) – Bali C Oct 19 '12 at 13:20

0 Answers0