View Full Version : New line difference in IE and Firefox
nani_chinni
29 Dec 2009, 11:49 PM
Hi,
I have used split method on string,by giving newline as a character and joined with comma.
I got results in Firefox, where as in IE , it shows string with newline and commas.
I want to know that how to give new line character in java script, for supporting both IE and Firefox.
Thanks,
chinni
Condor
29 Dec 2009, 11:57 PM
Use:
var lines = str.split(/\r?\n/);
nani_chinni
30 Dec 2009, 3:38 AM
Hi,
Thanks for reply. But my aim is to get string without new lines.
str = "a\nb\nc\nd";
previously i wrote as follows
str.split("\n").join();
I tried with your solution, but i got the result as follows.
a
,b
,c
,d
but i need output as a,b,c,d.
Thanks,
chinni
Condor
30 Dec 2009, 3:44 AM
Wouldn't it be better to use:
str = str.replace(/\r?\n/g, ',');
nani_chinni
30 Dec 2009, 3:54 AM
Hi,
Thanks for quick reply.
Its working.
I got the result.
Thanks,
chinni
nani_chinni
30 Dec 2009, 3:59 AM
Hi,
I checked for two answers. Both are working fine.
Actually i gave this value in (/\r?\n/) double quotes.
I removed quotes, and cheked.
I got result.
Sorry for this.
Any way thanks for giving reply.
Thanks,
chinni
Powered by vBulletin® Version 4.2.3 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.