DoomedLung wrote:
Hey Douglas, thank you for your reply...
Please quote appropriately when replying.
I have tried it your way and it doesn't work.
It will if you return an object. It's the way I'd normally create an
interface with "private" data or functions (rather than using the new
operator), but I didn't mention it for some reason.
var Expand = function() {
return {
init: function() {/* ... */}
};
}();
Again, unless there's some reason to introduce that extra execution
context, there's not much point in using it rather than using a simple
object literal. For example, if your childmenu method wouldn't be called
from the interface, it could be declared within the enclosing function
expression making it "private":
var Expand = function() {
function childMenu() {
/* ... */
}
return {
init: function() {
var element;
if (document.getElementById
&& (element = document.getElementById('expImg1')) {
element.onclick = childMenu;
}
}
};
}();
Mike