Search code examples
javascriptjqueryinternet-explorer-8jquery-address

IE8 not performing substring within jQuery Address


Within jQuery Address target[1] can be Films-by-Name-C7. I use the following to extract 7

(target[1].lastIndexOf('?') > 0 ?target[1].slice(0, target[1].indexOf("?")).substr((target[1].lastIndexOf('C')+1)):target[1].substr(-(target[1].length-target[1].lastIndexOf('C')-1)))

This works on all browsers except IE8. I don't know why it does this. When I try it out in Fiddle it also doesn't work. So how can i extract 7 from Films-by-Name-C7 in ie8?


Solution

  • IE<9 doesn't have an .indexOf() function for Array, to define the exact spec version, run this before trying to use it:

    Check this link

    As you need seven this can be the solution