解决方案 »

  1.   

    $('iframe').each(function(){
       $(this.contentWindow.document.body).find('a').each(function(){
          var t=$(this);
          if (t.text() == "cba") {
                   t.attr("id", "aaa");
                    t.removeAttr("onclick");t.click(function(){alert(1)});
           }
        })})
      

  2.   

    iframe加载的页面跨域没有?跨域当然没搞。。而且要在iframe的onload事件中修改,$()只是页面dom初始完毕,并不代表iframe也加载完了
        $(function () {
            $('iframe').load(function () {
                $(this).contents().find('a').each(function () {
                    if ($(this).text() == "cba") {
                        $(this).attr("id", "aaa");
                        $(this).removeAttr("onclick");
                        $(this).bind("click", function qwe() {
                            alert(1);
                        });
                    }
                });
            });
        });
      

  3.   

    页面之间要有关系才能调用,而且不能跨域引用关系参考这个:iframe和父页,window.open打开页面之间的引用
      

  4.   

    document.body.onclick=function(){alert(this.ownerDocument)}
    判断ownerDocument
      

  5.   


    location.pathname得到页面路径