怎么用JS代码实现在load页面时自动disable一些按键?

来源:百度知道 编辑:UC知道 时间:2024/06/07 05:51:48
在也面load完后还能再改吗?能的话怎么改?

<html>
<head>
<script>
var state=true;
function changeEnabled(){
var obj = document.getElementById("button1");
if(state){
obj.removeAttribute("disabled");
state = false;
}
else {
obj.disabled="true";
state = true;
}
}

function disableSomeone(){
document.getElementById("button1").disabled="true";
}
</script>
</head>
<body onload="disableSomeone()">
<input id="button1" type="button" value="我在变" />
<input type="button" value="点我" onclick="changeEnabled()" />
</body>
</html>

onLoad方法是当页面加载完毕后触发的一个事件。(好像没有加载中触发的事件)
<body onLoad="funcPageOnLoad();">
funcPageOnLoad()是个JavaScript方法,在这个方法里面写你想实现的功能吧。

可以在设置里面修改