2009-11-18 3 views

답변

0

어때 대략 window.frames[0].location.href?

iframe의 id을 알고있는 경우 document.getElementById("iframe1").src이 작동해야합니다.

0

"src"속성을 확인하십시오. 물론

document.getElementsByTagName('IFRAME')[0].contentDocument.location.href 

당신은 언제나 ID하여 잡아 수 :. 예를 들어

은 iframe을 가정

+1

이의 src 위치를 반환합니다. 사용자가 원본 페이지 위치에서 이동할 경우 어떻게됩니까? 페이지가있는 실제 위치가 필요합니다 ..! – rashcroft22

+0

예. 문서의 location.href를 확인하십시오. – smercer

0
function getUrl() 
{ 
    var pageFrame = $find("frame_id_goes_here", document); 
    if(pageFrame) { 
     return pageFrame.location; 
    } 
} 
0

이 페이지의 첫 번째이다 "your_iframe"] SRC에게 window.frames :

document.getElementById('myIframe').contentDocument.location.href 

contentDocument이 핵심입니다.

행운을 빈다.

1

iframe이 다른 도메인에 있거나 그렇지 않으면 same origin policy을 위반하는 경우 가능하지 않을 수 있습니다. 예를 들어, 페이지가 example.com/foo에 있고 iframe이 example.org/bar에있는 경우 위치를 가져올 수 없습니다. 같은 원본 정책을 위반하지 않는 경우

,이 같은 것을 사용할 수 있습니다

window.frames["iframeID"].location.href 
관련 문제