Can't access content of another frame in Chrome

后端 未结 4 477
感动是毒
感动是毒 2021-01-17 05:12

I have two frames. The pages in both frames come from the same domain (either localhost or a live domain - both using the same protocol).

The first frame needs to ac

4条回答
  •  鱼传尺愫
    2021-01-17 06:17

    I solved it by:
    1. Giving the target frame both a name and an id
    2. testing for both
    3. testing that a variable (finishedLoading) within the target frame was set to true
    (code altered to use === instead of == when testing finishedLoading)

    function isSurveyLoaded(){
      if(!(parent.frames["xsample"]  || parent.document.getElementById('xsample'))){
        return false;
      }
      else{
        if(parent.frames["xsample"]){
          target=parent.frames["xsample"];
        }
        else{
          target=parent.document.getElementById('xsample');
        }
      }
      if ((target.finishedLoading==='undefined') || (target.finishedLoading===false) ){
        return false;
      }
      else{
        return true;  
      }
    }
    

    Now simplified by using

    
    

提交回复
热议问题