By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,609 Members | 3,812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,609 IT Pros & Developers. It's quick & easy.

Replace Line breaks

P: n/a
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.
Sep 25 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Sep 25 '08 #2

P: n/a
On Sep 25, 8:19*pm, Sunny <sunnyluth...@gmail.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.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/>
FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
Sep 25 '08 #3

P: n/a
On Sep 25, 6:36 pm, Dr J R Stockton <J.R.Stock...@physics.orgwrote:
On Sep 25, 8:19 pm, Sunny <sunnyluth...@gmail.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.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/>
FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|
Hi Thanks, It fixed the problem.
Sep 26 '08 #4

P: n/a
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
Sep 26 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.