0

I'm building an application using KineticJS and with its latest update one of my text elements broke. The script that refers to it is in a onLoad handler and it's returning null. This is especially bizarre because when I run:

<div id="chatarea">
      <textarea id="chatBox"></textarea>
      <input type="text" id="chatInput">
</div>
<script>
    console.debug(document.getElementById('chatarea'));
</script>

It doesn't return null. But when I call that same debug function in my script.js on the load handler it returns null, and in the console this happens AFTER the one above! So it can't be that the script is running before the chatarea exists. I've read the KineticJS changelog and documentation and I haven't found anything to help me. If anyone could shed some light on this I would greatly appreciate it. I can't use an earlier version because Google Chrome's May 30 update broke some functionality in it.

<head>
    <script src="scripts/kinetic.js"></script>
    <script src="scripts/screen.game.js"></script>
</head>
4

1 回答 1

2

您必须在控制台中遇到错误,我认为您需要使用document.getElementById它,因为它是文档的一种方法,而不是全局窗口范围。

 console.debug(document.getElementById('chatarea'));
于 2013-06-10T04:24:26.970 回答