I'm having a problem with the function substr() working in different browsers, and I want to see if anyone else can enlighten me as to why it's not working correctly in Internet Explorer.
Here's a snippet of the function that isn't working:
"Element" is an HTML input that contains whatever value. What I'm trying to do here is return the last 3 characters of whatever string is in the text field input.Code:... var extension; extension = element.value.substr(-3); alert(extension); ...
It works fine in Mozilla Firefox, but in Intenet Explorer "extension" holds the entire value of "element.value", which I don't understand.
Anyone have any ideas as to why this is happening?
Edit: After searching around a bit I believe I've come to an anwser. Internet Explorer I guess has a bug where substr(num) is used, and num is a negative value, it just doesn't work and returns the entire string.


LinkBack URL
About LinkBacks







Reply With Quote