A couple language questions

K

Ken Kast

1) I want to test for the existence of a method o.m(), so I tried the line
if (o.m) ...
but the interpreter objects to the missing parentheses on m. (This is in
IE.) What is an appropriate approach for checking the existing of a
function?

2) I've got the following code
window.onresize = function {
....
f();
}
function f() {
....
}
<BODY onload="f();">

My question: if the resize event happens while f is executing, is the first
call to f (onload) flushed from the stack? If not, where in f is execution
resumed after the second call to f takes place in response to the resize
event?

Thanks.

Ken
 
J

Janwillem Borleffs

Ken Kast said:
1) I want to test for the existence of a method o.m(), so I tried the line
if (o.m) ...
but the interpreter objects to the missing parentheses on m. (This is in
IE.) What is an appropriate approach for checking the existing of a
function?

if (typeof o == 'object' && typeof o.m == 'function') {
// Function exists
}
2) I've got the following code
window.onresize = function {
...
f();
}
function f() {
...
}
<BODY onload="f();">

window.onresize = f; // this is sufficient
My question: if the resize event happens while f is executing, is the first
call to f (onload) flushed from the stack? If not, where in f is execution
resumed after the second call to f takes place in response to the resize
event?

My guess is that the function will be called twice after the calls have been
queued.


JW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top