在一个javascript文件里可以再写入的javascript判断代码吗?
比如有一个head.js文件,里面内容如下:
document.write("<table width=100% border=0 cellspacing=0 cellpadding=0>")
document.write(" <tr>")
document.write(" <td width=100% align=center><img src=http://images/fj_r1_c2.jpg width=802 height=30 border=0 usemap=#Map></td>")
document.write(" </tr>")
document.write("</table>")
........
document.write(" <input name=usernameshow type=text class=in size=6 maxlength=15> ")
........
其中上面....部分是一些省略的form内的代码,
我想再在里面写入一些代码,打开页面usernameshow自动获得焦点,如下:
document.write("<SCRIPT language=javascript>")
document.write("<!--")
document.write("function window_onload() {")
document.write(" usernameshow.focus();")
document.write("}")
document.write("//-->")
document.write("</SCRIPT>")
这样可以吗?我试了,不行,usernameshow没有获得焦点,但也没有提示错误,应该怎么写?