zhanghk(lion)方法是用button 的focus方法 focus说明: Causes a control to receive the focus, and executes the code specified by the onfocus event. Syntaxobject.focus()ResThis method fires the onfocus event.As of Microsoft® Internet Explorer 5, elements that expose the focus method must have the TABINDEX attribute set. 另getElementById是document的方法 Returns a reference to the first object with the specified value of the ID attribute.SyntaxoElement = document.getElementById(sIDValue) ParameterssIDValue Required. String that specifies the value of an ID attribute. Return ValueReturns the first object with the same ID attribute as the specified value.ResIf the ID value belongs to a collection, the getElementById method returns the first object in the collection.
function OnLoad()
{
document.getElementById("Cancel").focus();
}
</script>
<body onload="OnLoad()">
<input type="button" name="OK" id="OK" value="确定">
<input type="button" name="Cancel" id="Cancel" value="取消">
</body>
showModelDialog打开的页面里不是把focus()方法屏蔽掉了吗,怎么还可以用呢?
focus说明:
Causes a control to receive the focus, and executes the code specified by the onfocus event. Syntaxobject.focus()ResThis method fires the onfocus event.As of Microsoft® Internet Explorer 5, elements that expose the focus method must have the TABINDEX attribute set.
另getElementById是document的方法
Returns a reference to the first object with the specified value of the ID attribute.SyntaxoElement = document.getElementById(sIDValue)
ParameterssIDValue Required. String that specifies the value of an ID attribute.
Return ValueReturns the first object with the same ID attribute as the specified value.ResIf the ID value belongs to a collection, the getElementById method returns the first object in the collection.