Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2006
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Object creation function not working - not the regular stuff

    I'm working on a window interface class, and this is the function that creates windows.
    It has been through a few incarnations and I believe this to be the final, however, for some reason - It just won't show the DIV created, I have really no idea why.

    The function recieves a parameters object, validates the given values and sets default values if necessary.

    Aftwerwards, it creates the div element which is actually the window, and in case a requested parent element has been specified, the function will append the div to that node.

    The final part, which I guess is what's causing all the trouble, is the part which sets all of the visual properties of the window - css class, size, and position attributes.

    Maybe you could point out to principle errors or things like that, because I bet you the error is some coding problem I just don't know, since I'm not a big expert.

    Code:
    create_window({windowid: 'window2', class_name: 'popup_window', top: 323, left: 15});
    
    // Window Creation Function
    // windowid, controls, content, class_name, handle, transparent_drag, _width, _height, _parent, _position, _top, _left
    function create_window(params)
    {
        // Set default values
        var parent = ((typeof params.parent != 'object' || params.parent == null || params.parent == document) ? false : params.parent);
        var width = (typeof params.width != 'number' ? false : params.width);
        var height = (typeof params.height != 'number' ? false : params.height);
        var position = (typeof params.position != 'string' ? false : ((params.position != 'relative' && params.position != 'absolute' && params.position != 'static') ? 'relative' : params.position));
        var top = (typeof params.top != 'number' ? false : params.top);
        var left = (typeof params.left != 'number' ? false : params.left);
        var class_name = (typeof params.class_name != 'string' ? false : params.class_name);
    
        var window_div = document.createElement('DIV');
        if (parent)
        {
            parent.appendChild(window_div);
        }
    
        // Set optional basic CSS attributes
        if (class_name) {window_div.className = class_name}
        if (position) {set_style(window_div, 'position', position)}
        if (width) {set_style(window_div, 'width', width + 'px')}
        if (height) {set_style(window_div, 'height', height + 'px')}
        if (top) {set_style(window_div, 'top', top + 'px')}
        if (left) {set_style(window_div, 'left', left + 'px')}
    }

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by pilau View Post
    I'm working on a window interface class, and this is the function that creates windows.
    It has been through a few incarnations and I believe this to be the final, however, for some reason - It just won't show the DIV created, I have really no idea why.
    If I've understood, in the absence of the parent parameter, the created div isn't being appended to anything, and therefore isn't going to appear.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •