Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>firstly it have to be the same domain</p> <p>secondly it should be :</p> <pre><code> var frame = window.frames["tab"].document; var tags = frame.getElementsByTagName("a"); for (var i = 0; i &lt; tags.length; i++) { tags[i].href = 'javascript:alert("")'; } </code></pre> <p>or :</p> <pre><code>var frame = document.getElementById("tab").contentDocument; var tags = frame.getElementsByTagName("a"); for (var i = 0; i &lt; tags.length; i++) { tags[i].href = 'javascript:alert("")'; } </code></pre> <p>( in your code you only have the iframe tag, but you need the document of the frame of this tag )</p> <p>and thirdly you should either execute the code when iframe is loaded ( see the event onload of the iframe ), or use a setTimeout with a timeout enough big for any connection speed.</p> <p><strong>Edit :</strong></p> <p>In the comments it seems it's more about being on different domain, if it's the case you can't use javascript or frame to access or modify content accross domain.</p> <p>If it's a static page, just host it yourself, if it's dynamic and it's okay getting a proxy copy of the page, you could use several way :</p> <ol> <li>use a server side language ( like php ) on the same server to get and display the page, then use this page on the same server in the iframe ( then you will be able to have access to it )</li> <li><a href="http://developer.yahoo.com/yql/" rel="nofollow">yql</a> could be a way too it can get a web page with javascript</li> </ol> <p>Well it's hard to say not knowing what you want to do, maybe the owner of the website could do something, or for example if you just want to add tips on the website for your users making them install an user script wich will execute on the website could be a better way, without knowing why you need this and what's the situation, it's hard to say.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload