title: PHP/JS : Auto click button in iframe when its opened
body: <p>I'm trying to auto click a button in iframe (to add an article to the cart) when its opened from the result page.</p>
  
  <p>My code is working but the page is loading forever and it keep adding to the cart without stopping. </p>
  
  <p>RESULT PAGE :</p>
  
  <pre><code>&lt;form&gt;
  &lt;a href='#cart'&gt;Add&lt;/a&gt;
  &lt;div id='cart'&gt;
  &lt;iframe src="http://domaine.com/inframe.php" name = 'myIframe' &gt;&lt;/iframe&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>IFRAME:</p>
  
  <pre><code>&lt;form action='' method='post'&gt;
  &lt;input type='submit' id ="iframeAdd" name='iframeAdd' value='ADD'&gt;
  &lt;input  type='hidden' name='quantity'&gt;
  &lt;input type='hidden' name='item' value='1' /&gt;
  &lt;input type='hidden' name='price' value='20' /&gt;
  &lt;script&gt;
  window.onload = function(){
    document.getElementById('iframeAdd').click();
  }
  &lt;/script&gt;
  &lt;?php
  if ( isset( $_POST['iframeAdd'] ) ) {
  echo 'ADDED !';
  } else echo 'ERROR';
  ?&gt;
  &lt;/form&gt;
  </code></pre>