Wednesday, June 20, 2007

Dev: using setTimeout() to delay execution until .js file is successfully loaded

This is done only using html and js file, no XUL.

#1 Launch addButton() and addScript() at the same execution point:
- <a href="#" onclick="addButton();addScript('chrome://truetalk/content/data.js');">START</a>
- expected alert message is displayed.
- success, except in flock : Error: remoteValue is not defined

#2 Execute addScript() first, then addButton()
- addScript() -> addButton() -> click button -> alert messages
- <a href="#" onclick="addScript('chrome://truetalk/content/data.js');">START</a>
- expected alert message is displayed.
- success, except in flock: Error: remoteValue is not defined

#3 Append #2 by adding a new function [sendMessage()] in data.js, try to call it on button click

- oButton.setAttribute("onclick", "sendMessage();");
- success, except in flock: Error: remoteValue is not defined.


No comments: