2011-11-03 2 views
1

iframe이 jQuery를 내부 통제에 초점을 그리고 난설정 내가 iframe에 텍스트 상자에 포커스를 설정하는 코드를 검색 한

//get the IFRAME element - note no hashes in the name, we're using browser functionality 

var iframeRef = document.getElementById("IFRAMEID"); 
//focus the IFRAME element 
$(iframeRef).focus(); 
//use JQuery to find the control in the IFRAME and set focus 
$(iframeRef).contents().find("#CONTROLID").focus(); 

과 같은 코드를 찾았지만 몇 사람이 작동하지 않습니다이 코드는 .... 그래서 무엇을 할 것이라고 말했다 올바른 코드. 덕분에

+0

iframe 콘텐츠 페이지의 도메인이 상위 페이지와 동일합니까? –

답변

1

iframe의 상위 창이 동일한 도메인을 사용하는 경우에만 작동합니다.

+0

$ (iframeRef) .contents(). find ("# CONTROLID"). focus(); .contents() here .... plzz explain –

+0

'contents()'는 iframe 창 객체를 가져 와서 탐색을 위해 지역화합니다. – AlienWebguy

관련 문제