Non-breaking space in Javascript - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Non-breaking space in Javascript

EricChang591EricChang591 Posts: 4Member
How do I get two spaces together to display in Javascript?
For example (using Mozilla), let's say I have:
var text = "Hello World";
alert(text);

what comes out is "Hello World" instead of "Hello World"

I've tried setting a variable to " " and that doesn't work either.
Any ideas?

Comments

  • WaltPWaltP Posts: 335Member
    : How do I get two spaces together to display in Javascript?
    : For example (using Mozilla), let's say I have:
    : var text = "Hello World";
    : alert(text);
    :
    : what comes out is "Hello World" instead of "Hello World"
    :
    : I've tried setting a variable to " " and that doesn't work either.
    : Any ideas?
    :
    :
    try "Hello  World"

    ----------------
    Walt


  • EricChang591EricChang591 Posts: 4Member
    That does not work, as what comes out now is
    Hello  World

    where the entity is read as actual text.


    : : How do I get two spaces together to display in Javascript?
    : : For example (using Mozilla), let's say I have:
    : : var text = "Hello World";
    : : alert(text);
    : :
    : : what comes out is "Hello World" instead of "Hello World"
    : :
    : : I've tried setting a variable to " " and that doesn't work either.
    : : Any ideas?
    : :
    : :
    : try "Hello  World"
    :
    : ----------------
    : Walt
    :
    :
    :

  • lillulillu Posts: 308Member
    Hi all,

    var mystring = escape(" ")
    alert(mystring)

    the escape function will translate your string into a readable string for the webbrowser.

    Lillu

    : That does not work, as what comes out now is
    : Hello  World
    :
    : where the entity is read as actual text.
    :
    :
    : : : How do I get two spaces together to display in Javascript?
    : : : For example (using Mozilla), let's say I have:
    : : : var text = "Hello World";
    : : : alert(text);
    : : :
    : : : what comes out is "Hello World" instead of "Hello World"
    : : :
    : : : I've tried setting a variable to " " and that doesn't work either.
    : : : Any ideas?
    : : :
    : : :
    : : try "Hello  World"
    : :
    : : ----------------
    : : Walt
    : :
    : :
    : :
    :
    :

  • EricChang591EricChang591 Posts: 4Member
    [b][red]This message was edited by EricChang591 at 2003-8-4 11:7:15[/red][/b][hr]
    [b][red]This message was edited by EricChang591 at 2003-8-4 11:7:4[/red][/b][hr]
    Thanks, I used the escape(" "); where the space was holding down Alt and typing in 0160, which turned out to be %A0, which I then used to set a variable:
    var space = unescape("%A0");

    which FINALLY got me the results I needed.
    Thanks for the tips.

    : Hi all,
    :
    : var mystring = escape(" ")
    : alert(mystring)
    :
    : the escape function will translate your string into a readable string for the webbrowser.
    :
    : Lillu
    :
    : : That does not work, as what comes out now is
    : : Hello  World
    : :
    : : where the entity is read as actual text.
    : :
    : :
    : : : : How do I get two spaces together to display in Javascript?
    : : : : For example (using Mozilla), let's say I have:
    : : : : var text = "Hello World";
    : : : : alert(text);
    : : : :
    : : : : what comes out is "Hello World" instead of "Hello World"
    : : : :
    : : : : I've tried setting a variable to " " and that doesn't work either.
    : : : : Any ideas?
    : : : :
    : : : :
    : : : try "Hello  World"
    : : :
    : : : ----------------
    : : : Walt
    : : :
    : : :
    : : :
    : :
    : :
    :
    :







Sign In or Register to comment.