Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Chrome中的文本输入一经更改即给出未捕获的NotFoundError_Javascript_Google Chrome - Fatal编程技术网

Javascript Chrome中的文本输入一经更改即给出未捕获的NotFoundError

Javascript Chrome中的文本输入一经更改即给出未捕获的NotFoundError,javascript,google-chrome,Javascript,Google Chrome,我把我的问题归结为一个小例子: <!doctype html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Chrome test</title> <script> onload=function() { updateTagsList(); } function updateTagsList() {

我把我的问题归结为一个小例子:

<!doctype html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chrome test</title>
<script>
onload=function() {
  updateTagsList();
}
function updateTagsList() {
  var iel=document.getElementById("rftags");
  iel.innerHTML = '<input type="text" onChange="rfTagChanged()">';
}
function rfTagChanged() {
  console.log('rfTagChanged called - before calling updateTagsList');
  //debugger;
  updateTagsList();
}
</script>
</head>

<body>
<div class=inputarea id=rftags></div>
</body>
在我执行iel.innerHTML=。。。只有当我在填写文本项后“输入”(CR或如何称呼它…)时,才会出现此错误。如果我只在更改文本后单击某个位置,则不会发生错误,但会调用更改消息并调用更新方法-如预期的那样

经过一些调查,例如在指定位置停止调试器,我发现Chrome调用了两次rfTagChanged方法,一次是由于我在键盘上键入并保留文本项,另一次是由于UpdateTagList方法。第二次调用updateTagsList()时出错。(可能是因为DOM处于一个“边缘”状态,就像它在更新的中间一样?)

例如,在FireFox中,第二次更改调用不会发生,而在Chrome中,第二次调用仅在键入文本后添加“Enter”时发生

我还尝试过向新对象添加一个id,每次都使其成为不同的id,希望在添加的元素具有不同id时不会触发更改,但我仍然收到相同的错误,即第二次调用changed

直接调用updateTagsList,即onChange=“updateTagsList()”,会产生相同的错误

这是一个(已知的)bug还是Chrome的一个特性?(运行最新版本31.0.1650.63 m)
有什么解决办法的建议吗


谢谢你的帮助。

你到底想做什么?当用户键入内容时,重置输入?当用户尝试键入内容时,您正在替换整个输入元素。这种行为听起来像是Chrome中的一个bug,但你所做的似乎是反常的。@Barmar,为什么会出现bug?关于被另一个元素替换的元素,报告“找不到”错误是非常一致的。我怎么知道Chrome有bug的原因?就像你说的,它看起来很混乱,因为你正在把地毯从下面拉出来。很抱歉回复太晚。我在用户添加新项目时用新项目更新输入区域。
Uncaught NotFoundError: An attempt was made to reference a Node in a context where it does not exist.