【发布时间】:2011-09-10 18:47:03
【问题描述】:
我有这个脚本:
<html>
<head>
<script type="text/javascript">
function init(){
var extText = window.frames.messageTxt.document.body.lastChild.lastChild.data;
extText = extText.replace(/[\r\n]/g," ");
document.forms[0].nMessage.value = extText;
}
window.onload=init;
</script>
</head>
<body>
<iframe name='messageTxt' src='lineData.txt' style='display:none'></iframe>
<form>
<textarea name='nMessage'></textarea>
</form>
</body>
</html>
此代码打开一个文件(现在是 lineData.txt)并将其放在文本区域中。此代码适用于 Firefox 和 IE,但不适用于 Chrome。
问题出在
window.frames.messageTxt.document.body.lastChild.lastChild.data;
控制台在那一行告诉我:
未捕获的类型错误:无法读取未定义的属性“正文”
如何才能让它在 Chrome 上运行?
【问题讨论】:
-
它在 Chrome12 中适用于我。你能建立一个不适合你的例子吗?
标签: javascript google-chrome typeerror uncaught-exception