I’m using loadVars to import text from a text file and then put it into a dynamic text field - rendered in HTML. There is an extra space in the first line of text for some reason. I’ve checked the dynamic text field and theres no spaces or returns in it - its empty before putting the text into it.
Also, do you get the extra space if it’s NOT html-ed?
You can trim leading space using either of the following. However, it’s
probably better to not generate the space in the first place, in which case,
we’ll need to see your code.
// removing leading spaces from str...
while (str.charCodeAt(0) == 32)
{
str = String(str).substr(1);
}
// removing leading whitespace (incl. tabs, returns and so on) from str
while ((var ch = str.charCodeAt(0)) == 32 || ch == 9 || ch == 13 || ch == 10)
{
str = String(str).substr(1);
}
Jim
PS. I really hate the way the “as” tag destroys indenting on one-line IF, WHILE and FOR statements… Ordinaraily I would not use the curly braces, but they’re necessary here to show structure.