這個有很多思路。
1.onclick事件無效果;window.attachEvent("onload",initLoad);
function initLoad()
{
var oCheckBoxes=document.all.tags("input");
for(var i=0;i<oCheckBoxes.length;i++)
{
var isCheckBox=oCheckBoxes[i].type=="checkbox";
if(isCheckBox)
{
oCheckBoxes[i].setAttribute("onclick",function(){return false;});
}
}
}2.以下code:window.attachEvent("onload",init);
function init()
{
var oCheckBoxes=document.all.tags("input");
for(var i=0;i<oCheckBoxes.length;i++)
{
var isCheckBox=oCheckBoxes[i].type=="checkbox";
if(isCheckBox)
{
oCheckBoxes[i].setAttribute("onclick",fnCheck);
}
}
function fnCheck()
{
this.checked=!this.checked;
}
}
<form name="oForm">
<input type="checkbox" checked>a
<input type="checkbox">b
<input type="checkbox" checked>c
<input type="checkbox">d
<input type="checkbox" checked>e
<input type="checkbox">f
</form>

解决方案 »

  1.   

    加个disabled或者readonly属性,这样就没办法改变初始化的状态了
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title> new document </title>
    <meta name="generator" content="editplus" />
    <meta name="author" content="" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    </head><body><div id="kk">
    <input type="checkbox" id="" name="bb" />
    <input type="checkbox" id="" name="bb"  checked/>
    <input type="checkbox" id="" name="bb" />
    </div>
    <script type="text/javascript">
    <!--
    function addEvent(el,eventType,fn){
    if(el.addEventListener){
    el.addEventListener(eventType,fn,false);
    }else if(el.attachEvent){
    el.attachEvent("on" + eventType,fn);
    }else{
    el["on"+eventType]=fn;
    }
    }var ins = document.getElementById('kk').getElementsByTagName('input')
    for(var i=0;i<ins.length;i++){
    if(ins[i].type=='checkbox'){
    addEvent(ins[i],'click',new Function("var w = this;return function(){w.checked = !w.checked}").call(ins[i]))
    }
    }
    //-->
    </script>
    </body>
    </html>
      

  3.   

    兼容 ie ff opera