DOCTYPE related question

Discussion in 'Javascript' started by Tom de Neef, Feb 10, 2012.

  1. Tom de Neef

    Tom de Neef Guest

    I have a JavaScript function which extracts data from a genealogical html
    page and produces a layout chart of the family relationships which is then
    inserted in the page.
    It works fine on my testpages, which do not have a DOCTYPE (just start with
    <html>). The function is called from <body onload='functionCall()'>.
    The production site has pages which start with
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    ""><head <html
    Here, the chart is produced but all elements of the chart fall on each other
    with FF and Chrome (IE8 does fine).

    The function inserts nodes in the DOM. These nodes are created using:
    function newNode(x,y,width,height) {
    var node = document.createElement('div');'absolute'; = xOffset+x; = yOffset+y; = width; = height;
    return node;

    (xOffset and yOffset are global to the encapsulating function.)
    It appears that the positioning and size info will not be interpreted with
    this Transitional XHTML 1.0.
    The page was successfully checked as valid XHTML.
    I hope this is enough info for an advice how to modify.
    Thank you,
    Tom de Neef, Feb 10, 2012
    1. Advertisements

  2. You didn’t specify the URL.

    If adding a DOCTYPE declaration causes a problem, then the real problem
    was that your page design relies on Quirks Mode features. This can means
    dozens of things.
    Jukka K. Korpela, Feb 10, 2012
    1. Advertisements

  3. Check the error console, I am sure it warns that you are assigning
    values which are not proper CSS values as for instance 'left' needs a
    number plus a unit e.g. = xOffset + x + 'px';
    That way most of your dynamically assigned CSS values are ignored in
    standards mode by the browser.
    Martin Honnen, Feb 10, 2012
  4. Not Valid. (Is it so hard to copy and paste your code?)
    The relevance of this question to ECMAScript-based scripting is zero. It is
    a *CSS* issue. Read the CSS 2.1 Specification on the proper values for the
    `left' etc. properties. Those are most certainly not (you have not posted
    the *call*).
    Either the validator you use is borken or you have not copy-pasted the code.
    Probably it is where this is on-topic.

    Thomas 'PointedEars' Lahn, Feb 10, 2012
  5. Tom de Neef

    Jeff North Guest

    I hope you've wrapped your script within the CDATA element as this is
    a requirement for XHTML. = xOffset+x + "px"; = yOffset+y +"px"; = width + "px"; = height + "px";
    Jeff North, Feb 10, 2012
  6. Tom de Neef

    Tom de Neef Guest

    Spot on. Thank you.
    Tom de Neef, Feb 10, 2012
  7. Tom de Neef

    Tom de Neef Guest

    That was it. Thank you.
    Tom de Neef, Feb 10, 2012
  8. No, it is not. It is a recommendation (and I do not mean W3C
    Recommandation, although that applies as well).
    This script does not contain any `<' or `&'. Therefore, it does not need to
    be declared CDATA.

    Thomas 'PointedEars' Lahn, Feb 10, 2012
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.