Results 1 to 6 of 6

Thread: New line difference in IE and Firefox

  1. #1

    Smile New line difference in IE and Firefox

    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

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Use:
    Code:
    var lines = str.split(/\r?\n/);

  3. #3

    Default new line

    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

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Wouldn't it be better to use:
    Code:
    str = str.replace(/\r?\n/g, ',');

  5. #5

    Default

    Hi,

    Thanks for quick reply.
    Its working.
    I got the result.

    Thanks,
    chinni

  6. #6

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •