IE8 doesn’t support trim() on Strings (Firefox and other browsers do). To workaround this, you can perform the same operation using some regex on a String:
example.replace(/^s+|s+$/g, '')
… this matches one or more spaces anchored at the start of the line, or one or more spaces anchored at the end of the line, replaces with ”, and then globally replaces to do both.