• On DOM and Javascript

    Author
    Topic
    #431670

    I’m attemtping to create a colored division on a web page by means of the enclosed function. Can someone tell me why it doesn’t work? (IE6).

    function addDiv()
    {
    var division=document.createElement(‘div’);
    division.setAttribute(‘id’,’divdiv’);
    division.setAttribute(‘class’,’ccc’);
    document.body.appendChild(division);

    var ff=document.getElementById(‘divdiv’);
    ff.style.position=absolute;
    ff.style.top=100px;
    ff.style.left=100px;
    ff.style.width=100px;
    ff.style.height=100px;

    }

    Thanks in advance.

    Viewing 0 reply threads
    Author
    Replies
    • #1010907

      Try quoting your strings:

      ff.style.position="absolute";
      ff.style.top="100px";
      ff.style.left="100px";
      ff.style.width="100px";
      ff.style.height="100px";

    Viewing 0 reply threads
    Reply To: On DOM and Javascript

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: