title: How to modify a javascript function inside an iframe using bookmarklets?
body: <p>Lets say I have a html page with an iframe, which has its own javascript functions.</p>
  
  <pre><code>function foo(){
  //doSomething
  }
  </code></pre>
  
  <ul>
  <li>The web browser is pointed to the
  main page.</li>
  <li>Both the main page and the iframe are
  in the same domain.</li>
  </ul>
  
  <p>I can access/call those functions from the address bar.</p>
  
  <pre><code>javascript:document.getElementById('iframe').contentWindow.foo();
  </code></pre>
  
  <p>I can replace js functions in the main page by entering new function definitions inside the address bar.
  However it doesn't work on functions inside the iframe.</p>
  
  <pre><code>javascript:function foo(){//doSomethingElse}
  </code></pre>
  
  <p>This only seems to add that function to the main page. The iframe still uses its own foo function.</p>
  
  <p>I could open the iframe in a new tab, then it's possible to modify the function.
  But I wonder if it's possible to replace js functions which are inside an iframe by entering them in the address bar from the main page?</p>