2013-08-25 2 views
0

링크 코드를 수정하지 않고 iframe 내부에서 클릭 한 URL을 검색하려고합니다. 내 목표는 iframe 본문 밖에서 iframe에서 사용자가 클릭하는 URL을 얻는 것입니다.Iframe에서 링크를 클릭하면 URL을 가져 오는 방법은 무엇입니까?

document.write(location.href); 
document.write(window.location.href); 
document.write(window.location); 
document.write(document.URL); 
document.write(document.location); 
+0

iframe에 포함 된 콘텐츠를 수정할 수없는 경우 iframe의 소스 인 페이지 본문에 있어야합니다. –

+0

iframe에 포함 된 콘텐츠를 수정할 수 없습니다. 그래도 가능합니까? – user2714639

답변

0
document.getElementById("myFrame") 
.contentDocument.addEventListener("click", yourfunction, false); 

이 단지 같은 domain에서 컨텐츠를 작동 할 수 있습니다하지 마십시오 것을 : 난 이미 다음 시도했다.

+0

그게 문제입니다. 콘텐츠 또는 iframe 소스가 동일한 도메인에없고 소스를 수정할 수 없습니다. – user2714639

+0

그러면 콘텐츠를 보여주고있는 도메인을 구매하면됩니다. –

관련 문제