Nice and simple. Since IE and FF differ in splitting lines as do some others this should be nice and handy.
String.prototype.splitLines = function(){ try { var linesplit = this.split(/\n/); } catch(e) { var linesplit = this.split(/\r\n/); } return linesplit; }
Use as: var newarray = string.splitLines();
Greg says: Coding music... Greg says: Hmm... Greg says: I wouldn't rule it out. Chris 3.0 [New features? Yes.] says:
Greg says: If you think about machine code it's a bunch of 1s and 0s Chris 3.0 [New features? Yes.] says: Anything is possible. Greg says: Yeah try to code Metallica Chris 3.0 [New features? Yes.] says: Yeah, I'll get right on that... right after I learn to fly.
It does work with try and catch, I tested it. I thought so too at first so I was checking it returned a length greater or a length at all meaning it would be an array. However try and catch was shorter so I gave that a try and actually worked quite nicely.
Greg says: Coding music... Greg says: Hmm... Greg says: I wouldn't rule it out. Chris 3.0 [New features? Yes.] says:
Greg says: If you think about machine code it's a bunch of 1s and 0s Chris 3.0 [New features? Yes.] says: Anything is possible. Greg says: Yeah try to code Metallica Chris 3.0 [New features? Yes.] says: Yeah, I'll get right on that... right after I learn to fly.