Click to See Complete Forum and Search --> : creating a conditional function


Dudsmack
12-02-2003, 10:38 PM
Here's the problem: I need to create a function at the document level, e.g.

function document.myfunc()
{
//...code...
}

but I don't want this function to be created if a certain condifion is true, so in wrong syntax what I want to do is:


if condition
{
function document.myfunc()
{
//..code...
}

}
else
{
}

I need to avoid the functions creation under a condition so that it doesn't override a possible existing function. Is this possible?

gil davis
12-02-2003, 10:48 PM
You aren't too far off from reality.

document.myFunc = new Function() {...}

Dudsmack
12-02-2003, 10:50 PM
I should've figure that out....

Thnx!

fredmv
12-02-2003, 11:07 PM
Originally posted by gil davis
document.myFunc = new Function() {...} I'm sure you meant:document.myFunc = function() { ... }Just to avoid any confusion.