What’s with substr() in Internet Explorer’s javascript

When I moved to PHP I just coded perl in PHP, now I’m doing a bit of javascript, and yup I just do PHP in Javascript.

Anyway, today this internet explorer “bug” bit me in the ass Harold’s Home | substr() bug in Internet Explorer’s javascript. Now according to MSDN that’s actually a feature, but it sucks that it doesn’t work like you’d think, and more importantly Firefox does.

Anyway thanks to Richard Hayes, I’m sorted out. The correct code is :

ext = obj.item.value.substr(obj.item.value.length - 4);

That seems to work just fine.

And by the way PariahBB that cool BB whose interface literally eats the heart out of any other BB, NOW DOES RSS!!!

2 Responses to “What’s with substr() in Internet Explorer’s javascript”

  1. VOIP Says:

    Hello,

    do you have any sample code about PHP embedded in Javascript. I know it is possible because I saw this type of code sometime agor but just cant find it right now.

    thanks

    JAir

  2. Ryan Schmidt Says:

    The referenced MSDS page does not seem to make any statement as to the intended behavior of the function when start is negative. Since the behavior documented in everyone else’s JavaScript references is not observed in IE, it sounds like a genuine IE bug to me.

Leave a Reply