title: Click link inside iframe
body: <p>I want to click with the help of javascript on a link inside iframe, but this doesn't work.
  index.php load redirect.php inside frame then creat button outside iframe that click on the link <a href="http://www.yoursite.com/" rel="nofollow">http://www.yoursite.com/</a>.
  index.html:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;title&gt;Untitled Page&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
    function call() {
      var allAnc = document.getElementById("d").contentDocument.getElementsByTagName("a");
      for (var i = 0; i &lt; allAnc.length; i++) {
      if (allAnc[i].href.indexOf("http") &gt; 0) {
      (allAnc[i]).click();
      break;
      }
      }
    }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;input id="Button1" type="button" onclick="call()" value="button" /&gt;
  &lt;iframe id="d" src="redirect.html" width="100%" height=700"&gt;&lt;/iframe&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>redirect.html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt;&lt;title&gt;Avertissement de redirection&lt;/title&gt;
  &lt;script&gt;function go_back() {window.history.go(-1);return false;}function ctu() {var link = document &amp;&amp; document.referrer;var esc_link = "";if (link) {var e = (window &amp;&amp; window.encodeURIComponent) ? encodeURIComponent : escape;esc_link = e(link);}new Image().src ="/url?sa=T&amp;url=" + esc_link + "&amp;oi=unauthorizedredirect&amp;ct=originlink";return false;}&lt;/script&gt;
  &lt;/head&gt;
  &lt;body topmargin="3" bgcolor="#ffffff" marginheight="3"&gt;
  &lt;div class="a"&gt;
  &lt;div class="b"&gt;
  &lt;font size="+1"&gt;&lt;b&gt;Avertissement de redirection&lt;/b&gt;&lt;/font&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="c"&gt;
  &amp;nbsp;La page que vous consultiez essaie de vous rediriger vers &lt;a href="/url?q=http://www.yousite.com/&amp;amp;ei=2nPgT7uYJIP1-gb-kNiYDQ&amp;amp;sa=X&amp;amp;oi=unauthorizedredirect&amp;amp;ct=targetlink&amp;amp;ust=1340111586595170&amp;amp;usg=AFQjCNGP0YlzgPiD21g_9hQmBBb36l1THA"&gt;http://www.yoursite.com/&lt;/a&gt;.
  &lt;br&gt;
  &lt;br&gt;
  &amp;nbsp;Si vous ne souhaitez pas consulter cette page, vous pouvez &lt;a href="#" onclick="return go_back();" onmousedown="ctu();"&gt;revenir à la page précédente&lt;/a&gt;.
  &lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>