2011-11-03 3 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説明 –

+0

'contents()'はiframeウィンドウオブジェクトを取得し、それをトラバーサル用にローカライズします。 – AlienWebguy

関連する問題