a.html :
<html>
<head>
<script src=http://www.google.com/jsapi ></script>
<script>
google.setOnLoadCallback(function(){jQuery(pageLoad)});
google.load("jquery","1.3.2");
function pageLoad(){
$("iframe").contents().each(
function(){
$(this).find("div,a").each(
function(){
$(this).append("<input type=button />").click(
function(){alert(1);}) })})
}
</script>
</head>
<body>
<iframe src="b.html"></iframe>
<iframe src="b.html"></iframe>
</body>
</html>
b.html :
<div></div>
<a></a>