How do I use the JavaScript DOM to apply onclick
events to links inside of an iframe
?
Here\'s what I\'m trying that isn\'t working:
getElementsByTagName returns a NodeCollection, so you have to iterate throgh this collection and add onclick handler to every node in that collection. The code below should work.
var links = document.getElementById('myIframe').contentDocument.getElementsByTagName('a');
for(var i=0;i
also make sure, you run this code after the frames' content is loaded
embed_results.onload=function(){
// your code
}