Reputation: 36454
I have a script which is using this line as part of some geocoding.
var dms = String(dmsStr).trim().replace(/^-/,'').replace(/[NSEW]$/i,'').split(/[^0-9.,]+/);
It works fine in all browsers apart from IE, which is kicking out an error.
I'm sending it parameters.
0.5501039994056782
It's not my code I'm just debugging it. I'm assuming it could be a problem with Typecasting it to a string, given that it's clearly a number.
But I'd love some feedback.
Upvotes: 0
Views: 245
Reputation: 10315
the exact error is
"Object doesn't support property or method 'trim'"
so to solve you could do:
var dms = jQuery.trim(String(dmsStr)).replace(/^-/,'').replace(/[NSEW]$/i,'').split(/[^0-9.,]+/);
Upvotes: 0
Reputation: 101614
I don't think IE has trim()
. Try this:
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
}
See this SO question for more information
Upvotes: 0
Reputation: 342765
There is no String.trim()
in IE8. You can add it like this:
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
}
as per this answer.
Upvotes: 3