Sting methods get IE "not supported" errors

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jeff00seattle
Forum Commoner
Posts: 66
Joined: Sat Feb 28, 2009 3:27 pm

Sting methods get IE "not supported" errors

Post 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
Last edited by jeff00seattle on Mon Sep 28, 2009 11:11 am, edited 1 time in total.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: Sting methods get IE "not supported" errors

Post 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('')
jeff00seattle
Forum Commoner
Posts: 66
Joined: Sat Feb 28, 2009 3:27 pm

Re: Sting methods get IE "not supported" errors

Post 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
Post Reply