A
adambones
I am using the following code in my applications for kick-starting
JavaScript applications:
function App(d) {
this.d = d; this.n = d.createElement('div');
}
App.prototype.run = function() {
try {
this.d.body.appendChild(this.n);
this.d.body.removeChild(this.n);
f();
} catch (e) { setTimeout(arguments.callee, 50) }
}
// new App(document).run(function() { alert('Lets go') })
The problem I've had with using DOMContentLoaded is that you must be
sure that the document is *not* ready at the time you attach the event
- otherwise it will never fire, and in the case of FF which has no
readyState property, you cannot check that a document is already
loaded.
This issue is arising for me since my application requires me to check
the ready state of an iframed document from a parent window. In some
cases the framed document is already loaded by the time the parent
window code runs.
I'm posting this here because I'd appreciate if anyone can point out
any pitfalls in this approach. It's seems way too simple and obvious
to me, which leads me to fear I am missing something...
JavaScript applications:
function App(d) {
this.d = d; this.n = d.createElement('div');
}
App.prototype.run = function() {
try {
this.d.body.appendChild(this.n);
this.d.body.removeChild(this.n);
f();
} catch (e) { setTimeout(arguments.callee, 50) }
}
// new App(document).run(function() { alert('Lets go') })
The problem I've had with using DOMContentLoaded is that you must be
sure that the document is *not* ready at the time you attach the event
- otherwise it will never fire, and in the case of FF which has no
readyState property, you cannot check that a document is already
loaded.
This issue is arising for me since my application requires me to check
the ready state of an iframed document from a parent window. In some
cases the framed document is already loaded by the time the parent
window code runs.
I'm posting this here because I'd appreciate if anyone can point out
any pitfalls in this approach. It's seems way too simple and obvious
to me, which leads me to fear I am missing something...