2016年3月9日 星期三

[JQuery] 呼叫iframe內function


最近筆者在開發功能時,

遇到一個情況是當父頁面要呼叫Iframe中的JS檔某些Function時,該如何呼叫?


可使用以下的方式來呼叫Iframe中的ChangeValue Fuction:
    
   $("ResultIFrame").contentWindow.ChangeValue();

若是想要取得iframe內物件Back_Txt(如:Textbox、Button):
       var iframe = $("ResultIFrame").contentWindow.document;

        var BackTxt =iframe.getElementById("Back_Txt");

反過來,若是Iframe想要呼叫外層的 AdjustHeight Function時,則可使用parent來呼叫外層:
  parent.AdjustHeight ();

0 意見:

張貼留言