text function works in IE8, but not in FF3.6.13. Note the use of jQuery for position of canvas.

text function works in IE8, but not in FF3.6.13. Note the use of jQuery for position of canvas.

  1. function

    AddText(text, x, y, color, size) {

    labelCount++

    var position = $("canvas").position();

    var CanvasX = x + position.left + document.documentElement.scrollLeft;

    // -5 accounts for half the text height

    var CanvasY = y + position.top + document.documentElement.scrollTop - 5;

    var label = document.createElement("div");

    label.id =

    "label" + labelCount;

    label.style.position =

    "absolute";

    label.style.left = CanvasX;

    label.style.top = CanvasY;

    label.style.fontFamily =

    "sans-serif";

    label.style.fontSize = size;

    label.style.color = color;

    label.appendChild(document.createTextNode(text));

    document.body.appendChild(label);

    }

  2. Hi to all, first post here!
    What do I need to change in my function so that text appears correctly in FF?
    Note: Much of this function was derived using code from the book Javascript The Definitive Guide Fifth Edition.
    Thanks!