473,405 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Firefox removing spaces from my javascript strings

I'm sure it's something i'm doing wrong, I just can't see it.
I've set up a simple page with the following code:

<html>
<head>
<title>tester</title>
<script language="javascript" type="text/javascript">
alert('First String Second String');
</script>
</head>
<body>
<form id=main name=main onsubmit="return false;">
<table>
<tr><td colspan=2><input type=submit></td></tr>
</table>
</form>
<div id=maillink></div>
</body>
</html>

Opening this in IE pops up 'First String Second String',
as expected.
Firefox converts the multiple spaces into a single space giving: 'First
String Second String'

Can anyone tell me a way of getting Firefox to display the extra
spaces?

TIA,
Dave.

Oct 3 '06 #1
8 2481
<st*******@gmail.comwrote in message
news:11*********************@m7g2000cwm.googlegrou ps.com...
I'm sure it's something i'm doing wrong, I just can't see it.
I've set up a simple page with the following code:

<html>
<head>
<title>tester</title>
<script language="javascript" type="text/javascript">
alert('First String Second String');
</script>
</head>
<body>
<form id=main name=main onsubmit="return false;">
<table>
<tr><td colspan=2><input type=submit></td></tr>
</table>
</form>
<div id=maillink></div>
</body>
</html>

Opening this in IE pops up 'First String Second String',
as expected.
Firefox converts the multiple spaces into a single space giving: 'First
String Second String'

Can anyone tell me a way of getting Firefox to display the extra
spaces?
Try inserting a tab (\t):

alert('First String \t Second String');
Oct 3 '06 #2

McKirahan wrote:
>
Try inserting a tab (\t):

alert('First String \t Second String');
Thanks for the response.
The \t didn't work.
But using the escape slash gave me an idea. Using \u00A0 gives a
non-breaking space.
This seems to do the trick, but isn't ideal. I would still appreciate
any suggestions anyone may have!

Oct 3 '06 #3
st*******@gmail.com wrote:
alert('First String Second String');
Firefox converts the multiple spaces into a single space giving:
'First String Second String'
It doesn't for me. Can you provide an actual test url and tell us exactly
which version of FF you are using?

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Oct 3 '06 #4


st*******@gmail.com wrote:

alert('First String Second String');
Firefox converts the multiple spaces into a single space giving: 'First
String Second String'
That is a known bug with the alert dialog in Firefox, the spaces are
there in the string itself but the alert dialog collapses them when
displaying the string.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 3 '06 #5
JRS: In article <45***********************@newsspool2.arcor-online.net>,
dated Tue, 3 Oct 2006 18:12:10 remote, seen in
news:comp.lang.javascript, Martin Honnen <ma*******@yahoo.deposted :
>st*******@gmail.com wrote:
>alert('First String Second String');
>Firefox converts the multiple spaces into a single space giving: 'First
String Second String'

That is a known bug with the alert dialog in Firefox, the spaces are
there in the string itself but the alert dialog collapses them when
displaying the string.
If really necessary, maybe the string can be written to a new window.

Alternatively, as \u00A0 works, one might, if it works everywhere else,
use

function alert(S) { window.alert(S.replace(/ /g, " \u00A0")) }

Do I need to do that on my own site?

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Oct 3 '06 #6
Martin Honnen wrote:
That is a known bug with the alert dialog in Firefox, the spaces are
there in the string itself but the alert dialog collapses them when
displaying the string.
This isn't just happening in the alert dialogs, that was just an
example. Firefox seems to be collapsing all of my strings:

Here is an example using textContent
(http://starsky51.googlepages.com/testtemp.htm):
<html>
<body>
<div id=maillink></div>
<script language="javascript" type="text/javascript">
document.getElementById('maillink').textContent=
'First String Second String';
</script>
</body>
</html>

I am using 1.5.0.7. If no one else can replicate the problem then I'll
have to check my extensions. I've disabled GreaseMonkey, just in case
it was that, but no change.

Oct 4 '06 #7
st*******@gmail.com wrote:
This isn't just happening in the alert dialogs, that was just an
example. Firefox seems to be collapsing all of my strings:
Here is an example using textContent
document.getElementById('maillink').textContent=
'First String Second String';
This is to be expected, since whitespace in html documents is compressed
into a single space.

<div>First String Second String</div>

should never display all the spaces in any browser.
I am using 1.5.0.7.
The alert problem, at least, seems to be fixed in version 2.0rc1.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Oct 4 '06 #8

Matt Kruse wrote:
This is to be expected, since whitespace in html documents is compressed
into a single space.

<div>First String Second String</div>

should never display all the spaces in any browser.
Ah didn't think of it like that, thanks.
>
I am using 1.5.0.7.

The alert problem, at least, seems to be fixed in version 2.0rc1.
Thanks for your help.

Dave.

Oct 4 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: hokiegal99 | last post by:
This script works as I expect, except for the last section. I want the last section to actually remove all spaces from the front and/or end of filenames. For example, a file that was named " test ...
2
by: Stewart | last post by:
Originally posted in comp.lang.javascript: Newsgroups: comp.lang.javascript From: "Stewart" Date: 23 Aug 2005 02:50:04 -0700 Local: Tues, Aug 23 2005 10:50 am Subject: FireFox, RemoveChild,...
3
by: niconedz | last post by:
Hi The following code works fine in IE but not Firefox. It's a little script that zooms an image and resizes the window to fit. Can anybody tell me what's wrong? Thanks Nico == btw.....
12
by: shafiqrao | last post by:
Hello everyone, I have a script that runs in IE great, but in firefox it has problems. I understand that there are some objects that are accessed differently in IE and Mozilla. Can anybody let...
9
by: Dave | last post by:
Hi, I've been trawling the web for answer to my problem with no luck although I'm hardly alone it seems! Below is the generated source for an ASP page that posts a value called 'album' to...
4
by: evgenyg | last post by:
Hello ! We have the following situation - when Ajax request is sent what's being returned by the server is usually an XML (which is used for DOM updates) but sometimes it's HTML which is a whole...
2
by: beatTheDevil | last post by:
Hey guys, As the title says I'm trying to make a regular expression (regex/regexp) for use in removing the comments from code. In this case, this particular regex is meant to match /* ... */...
11
by: ramu | last post by:
Hi, Suppose I have a string like this: "I have a string \"and a inner string\\\" I want to remove space in this string but not in the inner string" In the above string I have to remove...
3
by: SAL | last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps section of either web.config or machine.config but it didn't work. It seems that most pages in my webapp are okay but a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.