Question: I need a function that needs to be executed on document.ready and available to window.onload function ...

How can I do that?

```
$(document).ready(function someFunction() {
    execute something and pass the results to window.load
}
);

$(window).load(Need results of somefunction);​

```

Answer: 
You can share the result of a function call by assigning it to some variable in scope.

```
(function(){
   var result;
   $(document).ready(function(){
      result = 'something';
   });

   $(window).load(function() {
       console.log(result); //something
   });

}());

```
Since you need to do something on dom ready, then access it on window load, nest the window load binding method inside the dom ready method.

```
$(document).ready(function () {
    // do something
    var somevar = "Hello World!";
    $(window).on("load", function () {
        console.log(somevar); // Hello World!;
    });
});

```