How to make a button in an iframe trigger a function on a specific object in the parent window?
<p>I have the following 2 html files, INDEX.HTML and FRAME.HTML, which is shown in an iframe on INDEX.HTML. When I click button1, I get the alert "action1: your value 1". A click on button2 shows the alert "action1: your value 2".</p>

<p>My question is, how can I make an onclick on button3 that triggers action2 on the myfunction object bound to button1? This should give me the alert "action2: your value 1".</p>

<p>INDEX.HTML:</p>

<pre><code>    &lt;a id="button1" href="#"&gt;BUTTON 1&lt;/a&gt;
    &lt;a id="button2" href="#"&gt;BUTTON 2&lt;/a&gt;

    &lt;iframe id="frameforbutton3" src="frame.html"&gt;&lt;/iframe&gt;

    &lt;script type="text/javascript"&gt;
        //&lt;![CDATA[
        $.fn.myfunction = function(value) {
            $(this).click(function() {
                action1();
                return false;
            });
            var action1 = function() {
                alert("action1: " + value);
            }
            var action2 = function() {
                alert("action2: " + value);
            }
        }
        $(function() {
            $("#button1").myfunction("your value 1");
            $("#button2").myfunction("your value 2");
        });
        //]]&gt;
    &lt;/script&gt;
</code></pre>

<p>FRAME.HTML:</p>

<pre><code>    &lt;a id="button3" href="#"&gt;BUTTON 3&lt;/a&gt;
</code></pre>
