如何获取表格焦点?
如表格ID和NAME均为 test ,如何在页面载入时获得焦点?

解决方案 »

  1.   

    如果希望页面加载时自动获得焦点,只需要将<body>改成
    <body onload="javascript:document.all.test.focus();"><html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>new page</title>
    </head>
    <body>
    <table id=test name=test border=1 width=400 onfocus="javascript:alert('table已经获得焦点!');">
    <tr>
    <td> </td><td> </td><td> </td><td> </td>
    </tr>
    </table>
    <input type=button onclick="javascript:document.all.test.focus();" value="获得焦点">
    </body>
    </html>