javascript - Is it possible to run a function that is '2-deep' within another function? -


I need to execute a function from a window.onload event. I want to lie within the function's function. I know that I can run the function

  function1 () {function2 ()) from another function; } Function2 () {... a process ...}   

But since I did not run the 'code' window.onload event within this 'overall' function May be on the 'top layer' I tried to do this, but it was not working, but basically I think that this is what I want to do.

  & lt; Script & gt; Function () {function1 () {.. some stuff ..} function2 () {function1 (); }} Window.onload = function2; & Lt; / Script & gt;   

I can not just run the function 1 from the window.onload event because this object is bound by the onclick event.

How to do any suggestions I can solve it ??

You should study and learn different JavaScript methods, which will code you in your candidate manner.

There is a great resource and will show you the things you should know.

Each pattern gives details of implementation, benefits and disadvantages.

Here is an example that uses the module pattern:

  // global module var myModule = (function () {function privateMethod1 () {...} Function privateMethod2 () {. ..} return {publicMethod: function () {privateMethod1 ();}}}}) (); MyModule.publicMethod ();    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -