<p>I have an onclick handler for an &lt;a&gt; element (actually, it's a jQuery-created handler, but that's not important).  It looks like this:</p>

<pre><code>function handleOnClick() {
    if(confirm("Are you sure?")) {
        return handleOnClickConfirmed();
    }
    return false;
}
</code></pre>

<p>From this function, the <strong>this</strong> object is accessable as the &lt;a&gt; element clicked.  However, handleOnClickConfirmed's <strong>this</strong> is a Window element!  I want handleOnClickConfirmed to have the same <strong>this</strong> as handleOnClick does.  How would I do this?</p>

<p>(I know I can pass <strong>this</strong> as an argument to handleOnClickConfirmed, but some of my code already uses handleOnClickConfirmed and I don't want to have to rewrite those calls.  Besides, I think using <strong>this</strong> looks cleaner.)</p>

The following ought to do it:
```
```
function handleOnClick() {
    if( confirm( "Sure?" ) ) {
        return handleOnClickConfirmed.call( this );
    }
    return false;
}
```
```
The
```
call()
```
function attached to
```
Function
```
objects is designed to allow this; calling a function with a desired context. It's an extremely useful trick when setting up event handlers that call back into functions within other objects.