Tuesday, January 6, 2015

In-Game Browser Note: No JavaScript trim()

A quick note for anyone that develops or wants to develop dynamic web pages for use in Eve -- if you didn't already know, the Eve in-game browser does not support the JavaScript string trim() function.

 If you need to trim white space from the front and end of a string, you will need to supply your own trimming function. Here is one that is short and sweet, (albeit not so intuitive given that it uses a regular expression) courtesy of w3schools.com.

function myTrim(x) { 
    return x.replace(/^\s+|\s+$/gm,''); 
}

No comments:

Post a Comment