function AddNew(){
...........
newCell2.firstChild.focus();
}
...........
newCell2.firstChild.focus();
}
解决方案 »
- 前辈请教,在网页中用js语言删除mdb数据中一行不成功,谢谢!
- 请问如何用JS打开一个文件保存对话框,然后下载指定文件到本地目录?
- js获取浏览器body高度和宽度的问题
- 在js里删除xml根节点问题
- 这个网站结合了电子地图的技术,这是怎样实现的(WEB 2.0)
- javascript函数
- 100给第一位帮我解决问题的朋友!!!
- 如何实现MSDN上的菜单
- 一个变色表格,请帮忙修改一下,使鼠标移动到表格选项时该表格中的文字颜色不变。
- Javascript中如何取得IMG标签距离文档窗口坐标(0,0)的距离(象素)?
- 在页面中写的JS代码怎样分离到JS脚本文件?急,在线等待
- iframe中内嵌iframe,如何使链接在最顶级打开?
newCell1 = tr.insertCell(0);
newCell1.innerText="自动编号";
newCell2 = tr.insertCell(1);
newCell2.innerHTML="<input type='text' name='power_name'size='100' onFocus='getfocus()' size=30 maxlength=50>";
newCell2.children[0].focus();
}
这个函数错在那里呢?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="mytable">
<tr>
<td width="18%"><div align="center"><a href="#" onClick="AddNew()">新增</a></div></td>
<td width="82%"> </td>
</tr>
<tr bgcolor="#FF0000">
<td> </td>
<td> </td>
</tr>
</table></body>
</html>
<script language="JavaScript">
function AddNew(){
var tr = mytable.insertRow(mytable.rows.length);
newCell1 = tr.insertCell(0);
newCell1.innerText="自动编号";
newCell2 = tr.insertCell(1);
newCell2.innerHTML="<input type='text' name='power_name'size='100' onfocus='getfocus()' size=30 maxlength=50>";
//***************我的加的语句*****************************************************
newCell2.firstChild.focus();
//*******************************************************
}
function getfocus(){
event.srcElement.style.background="ffff00";
event.srcElement.focus();
event.srcElement.select();
}</script>
能不能在getfocus()里进行为它进行设置焦点呢?因为在function deptUpdate(){
opFlag = 0;
var power_id = window.mytable.rows[Count].cells[0].innerHTML;
var val = window.mytable.rows[Count].cells[1].innerHTML;
window.mytable.rows[Count].cells[1].innerHTML = "<input type='text' name='power_name'size='50' onfocus='getfocus()' value='"+val+"' onkeyup='upenter2()' onblur='lostfocus2()' size=30 maxlength=50>";
}不知在这里有怎样进行设置焦点了?