Page 1 of 1

Sting methods get IE "not supported" errors

Posted: Mon Sep 28, 2009 10:43 am
by jeff00seattle
Hi

I am having a problem whereby commonly expected JavaScript string methods are not supported, for example split(), they return the following error in the IE8 script debugger:
Object doesn't support this property or method
Why would this occur and how can make sure that string methods are made available?

This seems to be a common problem but I have not found a definitive answer.

Thanks

Jeff in Seattle

Re: Sting methods get IE "not supported" errors

Posted: Mon Sep 28, 2009 11:10 am
by kaszu
split is supported by all major browsers. Make sure you are calling this method on string not on other type variable

Code: Select all

var x = ...;
//instead of 
var result = x.split('');
//do type casting to make sure we are operating with string
var result = String(x).split('')

Re: Sting methods get IE "not supported" errors

Posted: Mon Sep 28, 2009 12:05 pm
by jeff00seattle
I think this is a IE8 script debugger issue.

In FireBug, the code passes right on through.
But in IE8, errors in script pops up JScript debugger error dialog, and I believe that JScript does not recognize JavaScript String.

var trimmed = query.trim();

Variable: query
Value: "Mom Apple Pie"
Type: String
JScript Debugger:
Object doesn't support this property or method
Is there a way for IE to use a JavaScript debugger vs a JScript debugger?

Thanks

Jeff in Seattle