Firefox kills option.value white-space

Discussion in 'Javascript' started by Richard Maher, Jul 3, 2007.

  1. Hi,

    Can someone please show me how to tell Firefox to preseve white-space when
    returning the selectList.option[n].value attribute?

    I have change the style so that the white-space is preserved on the screen,
    but for some bizarre reason when I try to substring out a series of bytes
    (aka a fixed-length string or field) from a given option it squashes
    everything up and corrupts the result.

    Cheers Richard Maher

    BTW. Works fine on IE.
     
    Richard Maher, Jul 3, 2007
    #1
    1. Advertising

  2. Richard Maher

    RobG Guest

    On Jul 3, 3:44 pm, "Richard Maher" <>
    wrote:
    > Hi,
    >
    > Can someone please show me how to tell Firefox to preseve white-space when
    > returning the selectList.option[n].value attribute?
    >
    > I have change the style so that the white-space is preserved on the screen,
    > but for some bizarre reason when I try to substring out a series of bytes
    > (aka a fixed-length string or field) from a given option it squashes
    > everything up and corrupts the result.


    The value of an option element is CDATA[1], about which the W3C HTML 4
    specification says:

    "User agents may ignore leading and trailing white space
    in CDATA attribute values (e.g., " myval " may be
    interpreted as "myval"). Authors should not declare attribute
    values with leading or trailing white space."

    <URL: http://www.w3.org/TR/html4/types.html#type-cdata >


    > BTW. Works fine on IE.


    Hooray for IE, however both IE and Firefox are consistent with the
    spec.


    1. <URL: http://www.w3.org/TR/html4/interact/forms.html#adef-value-OPTION
    >

    --
    Rob
     
    RobG, Jul 3, 2007
    #2
    1. Advertising

  3. Hi Rob,

    Thanks for the reply.

    > The value of an option element is CDATA[1], about which the W3C HTML 4
    > specification says:


    [ambiguous non-committal crap :-]

    Anyway, I was able to work out that my x.options[x.length] = new
    Option(string,pos) should've been (string,string) and then if I returned the
    options[n].VALUE rather than .TEXT I managed to get the white-space intact.

    Just another part of browsers' rich tapestry I suppose :)

    Please bear with me as there's bound to be a few more of these. I'm not an
    IE (or Microsoft) lover, but (at first glance) Firefox doesn't seem to be
    all it's cracked up to be. How do you get Firebug going 'cos at least IE
    gave you the line number it barfed at. (Come to think of it, at least it
    barfed in the first place and let you double-click on the error rather than
    this Firefox deathly silence)

    Cheers Richard Maher

    "RobG" <> wrote in message
    news:...
    > On Jul 3, 3:44 pm, "Richard Maher" <>
    > wrote:
    > > Hi,
    > >
    > > Can someone please show me how to tell Firefox to preseve white-space

    when
    > > returning the selectList.option[n].value attribute?
    > >
    > > I have change the style so that the white-space is preserved on the

    screen,
    > > but for some bizarre reason when I try to substring out a series of

    bytes
    > > (aka a fixed-length string or field) from a given option it squashes
    > > everything up and corrupts the result.

    >
    > The value of an option element is CDATA[1], about which the W3C HTML 4
    > specification says:
    >
    > "User agents may ignore leading and trailing white space
    > in CDATA attribute values (e.g., " myval " may be
    > interpreted as "myval"). Authors should not declare attribute
    > values with leading or trailing white space."
    >
    > <URL: http://www.w3.org/TR/html4/types.html#type-cdata >
    >
    >
    > > BTW. Works fine on IE.

    >
    > Hooray for IE, however both IE and Firefox are consistent with the
    > spec.
    >
    >
    > 1. <URL: http://www.w3.org/TR/html4/interact/forms.html#adef-value-OPTION
    > >

    > --
    > Rob
    >
     
    Richard Maher, Jul 3, 2007
    #3
  4. Hi Duncan,

    "Duncan Booth" wrote: -
    > A lot of things in Firebug's console are clickable: click on the line
    > number associated with an error message and it jumps you to the relevant
    > line in the debugger, click on an object value and you can browse its
    > properties. Use console.log to output clickable objects in tracing
    > statements:


    Now this is excellent! Thanks for the pointer.

    I had to get the console up via "tools/error console" but now I'm there and
    love what I see so far.

    Cheers Richard Maher

    "Duncan Booth" <> wrote in message
    news:Xns99628D03413Fduncanbooth@127.0.0.1...
    > "Richard Maher" <> wrote:
    >
    > > How do you get Firebug going 'cos at least IE
    > > gave you the line number it barfed at. (Come to think of it, at least
    > > it barfed in the first place and let you double-click on the error
    > > rather than this Firefox deathly silence)

    >
    > If you get a javascript error then firebug will tell you this in red near
    > the right hand end of the status bar. e.g. '1 Error'. Click on this and it
    > will open Firebug's console view (or open firebug with F12 and select the
    > console view manually). Once in the console view you should be able to see
    > the error message.
    >
    > A lot of things in Firebug's console are clickable: click on the line
    > number associated with an error message and it jumps you to the relevant
    > line in the debugger, click on an object value and you can browse its
    > properties. Use console.log to output clickable objects in tracing
    > statements:
    >
    > console.log('Foobar current value is %o', foobar);
    >
    > Also at the console prompt you can type in an expression and again the
    > result (if it isn't just a simple value) can be clicked on and browsed.
     
    Richard Maher, Jul 4, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,955
    Bryan Bullard
    Jul 11, 2003
  2. Christian Seberino
    Replies:
    21
    Views:
    1,767
    Stephen Horne
    Oct 27, 2003
  3. Ian Bicking
    Replies:
    2
    Views:
    1,081
    Steve Lamb
    Oct 23, 2003
  4. Ben C
    Replies:
    6
    Views:
    2,227
    Leif K-Brooks
    Jan 28, 2007
  5. kaeli
    Replies:
    2
    Views:
    98
    Lasse Reichstein Nielsen
    Dec 3, 2003
Loading...

Share This Page