Replace Line breaks

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sunny

    Replace Line breaks

    Hi does anyone knows, How to remove line breaks from a string using
    javascript.
    I have a string like:
    <div <div class="style1"> Yates<br>-47.13

    but somehow the javascript is displaying string "-47.13"
    as
    -
    47.13
    It is treating a "-" sign as a line break.
    Any comments.
  • Conrad Lender

    #2
    Re: Replace Line breaks

    On 2008-09-25 21:19, Sunny wrote:
    but somehow the javascript is displaying string "-47.13"
    as
    -
    47.13
    It is treating a "-" sign as a line break.
    That's not possible. Something else is causing line breaks here. Maybe
    one of your <div>s is too narrow.

    - Conrad

    Comment

    • Dr J R Stockton

      #3
      Re: Replace Line breaks

      On Sep 25, 8:19 pm, Sunny <sunnyluth...@g mail.comwrote:
      Hi does anyone knows, How to remove line breaks from a string using
      javascript.
      I have a string like:
      <div <div class="style1"> Yates<br>-47.13
      >
      but somehow the javascript is displaying string "-47.13"
      as
      -
      47.13
      It is treating a "-" sign as a line break.
      Any comments.
      Wrapping the entire number -47.13 as <nobr>-47.13</nobrcould fix it,
      at least in IE7.

      --
      (c) John Stockton, near London, UK. Posting with Google.
      Mail: J.R.""""""""@ph ysics.org or (better) via Home Page at
      Web: <URL:http://www.merlyn.demo n.co.uk/>
      FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|

      Comment

      • Sunny

        #4
        Re: Replace Line breaks

        On Sep 25, 6:36 pm, Dr J R Stockton <J.R.Stock...@p hysics.orgwrote :
        On Sep 25, 8:19 pm, Sunny <sunnyluth...@g mail.comwrote:
        >
        Hi does anyone knows, How to remove line breaks from a string using
        javascript.
        I have a string like:
        <div <div class="style1"> Yates<br>-47.13
        >
        but somehow the javascript is displaying string "-47.13"
        as
        -
        47.13
        It is treating a "-" sign as a line break.
        Any comments.
        >
        Wrapping the entire number -47.13 as <nobr>-47.13</nobrcould fix it,
        at least in IE7.
        >
        --
        (c) John Stockton, near London, UK. Posting with Google.
        Mail: J.R.""""""""@ph ysics.org or (better) via Home Page at
        Web: <URL:http://www.merlyn.demo n.co.uk/>
        FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
        Hi Thanks, It fixed the problem.

        Comment

        • Conrad Lender

          #5
          Re: Replace Line breaks

          On 2008-09-26 15:16, Sunny wrote:
          >Wrapping the entire number -47.13 as <nobr>-47.13</nobrcould fix it,
          >at least in IE7.
          ....
          Hi Thanks, It fixed the problem.
          <nobris not (and never was) part of the HTML specification. Even if it
          had been, it would be deprecated by now, because display formatting is
          the job of CSS. A correct and portable way to prevent line breaks would
          be something like this:

          <style type="text/css">
          ..nobr { white-space: nowrap; }
          </style>
          ....
          <span class="nobr">-47.13</span>


          - Conrad

          Comment

          Working...