2014-01-23 44 views
3

我似乎無法找到使用父技巧來顯示iframe頂部的jquery ui對話框的正確解決方案。如何在iframe外部的父窗口顯示Jquery UI對話框

這是我的實際例子: http://jsfiddle.net/NZ3eH/2/

家長:

一個div加載父頁面

<div> 
    <iframe src="http://labs.**/jquery/dialog.html" width="400" height="300" frameborder="0" scrolling="no" id="iframe"></iframe> 
</div> 

IFRAME

而上的iframe JS on dialog.html

<script> 
    $(function() { 
     $("#create").parent().click(function() { 
      $("#dialog-modal").dialog("open"); 
     }); 

     $("#dialog-modal").dialog({ 
      autoOpen: false, 
      height: 140, 
      modal: true 
     }); 
    }); 
</script> 

所有的JS都在iframe中。

是否可以讓對話框顯示在iframe之上?它似乎鎖定它。

回答

2

嘗試用下面的代碼

$("#create").click(function() { 
    parent.$("#dialog-modal").dialog("open"); 
}); 

parent.$("#dialog-modal").dialog({ 
    autoOpen: false, 
    height: 140, 
    modal: true 
}); 
+0

我試圖修改它,現在的錯誤是...錯誤:權限被拒絕訪問屬性「$」 [打破這個錯誤] \t 父$ (「#dialog-modal」).dialog(「open」); –

+0

好的..你基本上想要在父頁面內點擊子頁面內的按鈕打開對話框。 –

相關問題