动态创建div

function creatediv(objname)
{
    var objdiv = document.createElement("div");
    objdiv.id =objname;
    objdiv.innerHTML=objname;
    objdiv.style.top = 100;
    objdiv.style.left = 100;
    objdiv.style.background = '#FFFF00';
    objdiv.style.visibility = 'visible';
    objdiv.style.width = 500;
    objdiv.style.height = 500;
    
    document.body.appendChild(objdiv);
    document.getElementById(objname).onmouseover = function()
    {
        alert(this.id);
    };
}

上面的代码是没什么问题的,但有一种情况,就是FF提交表单时,
这样创建控件,会受安全限制,不一定好用的。

Leave a Reply

Your email address will not be published. Required fields are marked *

*