2013-03-30 2 views
0

그래서 잠시 동안 자바 스크립트를 만들 수있는 해결책을 찾고있었습니다. jQuery는 특정 클래스 나 id 요소를 iFrame에서 검색합니다. 그런 다음 내부의 html을 가져옵니다. (예 : <a id="link">Here's a link</a>). 그 다음 5 초마다이 기능을 재생합니다. 이것이나 튜토리얼에 대한 좋은 해결책을 아는 사람이 있습니까?iFrame에서 요소를 10 초마다 html로 가져 오기

나는 var inf = $('#iframeid').contents().find('#theid').html(); 함수를 시도했지만 성공하지 못했습니다.

+1

가 같은 도메인에 theiframe 소스입니까? http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe을 참조하십시오. –

답변

0

이 시도 :

function GetFrameData() { 
    var $MyFrame = $("#iframeid"); 

    // You need to wait for the iFrame content to load first 
    // So, that the click events work properly 
    $MyFrame.load(function() { 
     var frameBody = $MyFrame.contents().find('body'); 
     var inf = frameBody.find('#theid').html(); 
    }); 
} 

// Call the function every 5 seconds 
setInterval(GetFrameData, 5000);