String calculated Width - Node.js String

Node.js examples for String:Algorithm

Description

String calculated Width

Demo Code


String.prototype.calculatedWidth = function m(p, o) {
    if (p === undefined) {
        p = ""/*  w w w .j  a v  a 2 s .c o  m*/
    }
    if (p !== l) {
        l = p;
        b.style.cssText = p || ""
    }
    f();
    b.innerHTML = (function () {
        return this.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
    }).apply(this);
    return b.offsetWidth
};

Related Tutorials