Question: My [Code](http://jsfiddle.net/DW55V/) :

```
<a href="javascript:void(0);" onclick="myFunction(this)">Call Function</a>​

$(window).load(function () {
    function myFunction(param) {
        console.log("called");
    }
});

```

as you can see, I can't access to that function (is inside the load scope). I can't also use handlers inside the load, because I'm in a scenario where (don't ask me why, it's a google maps infowindow policy) handlers will be deleted when I create some element (so, where I should invoke that function from an object).

So, is there a "trick" to call a function inside the load scope?

Answer: 
You can declare it as a variable outside the scope of the load function, and the set the value inside the scope of the load function, and it will be accessible, but it will only call the function after the variable is set i.e. after the load function has executed :

```
var myFunction;

$(window).load(function () {
    myFunction = function(param) {
        console.log("called");
    }
});

```

[**FIDDLE**](http://jsfiddle.net/KQJSq/)

Or how I'd do it:

```
<a href="#" id="myAnchor">Call Function</a>​

```

--

```
$(function() {
    $("#anchor").on('click', function(e) {
        e.preventDefault();  
        console.log("called");
    });
});

```

Google maps have their own way of handling this:

```
google.maps.event.addListener(marker, 'click', function(event) { ...

```
why not do this? 

```
function myFunction(param) {
    console.log("called");
}

$(window).load(function () {
    //Any code you actually need in the load
});

```