No, it has nothing to do with innerHTML
. In the call to lastIndexOf
, the »
entity is not expanded as it is in the HTML code; instead it is considered as a raw string. Replace it with the actual character and it will work:
var index = str.lastIndexOf("»");
casablanca
2010-07-02 05:10:31