showModelDialog方法会自动获得焦点的吧

解决方案 »

  1.   

    <script>
    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>
      

  2.   

    问zhanghk(lion):
     showModelDialog打开的页面里不是把focus()方法屏蔽掉了吗,怎么还可以用呢?
      

  3.   

    zhanghk的方法不是用showmodeldialog的。
      

  4.   

    但是zhanghk的方法难道不需要新开一个窗口吗?
      

  5.   

    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&reg; 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.