getElementById does return null

Posted by pbcoder on Stack Overflow See other posts from Stack Overflow or by pbcoder
Published on 2010-12-30T17:50:23Z Indexed on 2010/12/30 17:54 UTC
Read the original article Hit count: 130

Filed under:
|

I have following function:

$('canvas').createWindow('xyz', 500, 600);

And js-code behind is:

    var $ = function(element) {
        if (this.constructor !== $) {
            return new $(element);
        }

        alert(element);
        var windowObj = document.getElementById(element);

        this.createWindow = function(src, width, height) {          
            if(width != "" && height != "") {
                windowWidth = windowObj.style.width = width + 'px';
                windowHeight = windowObj.style.height = height + 'px';
            }
        };
    };

But the problem is that JS says windowObj is null, alert(element) works fine! Thanks for your help!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html