javascript
  • ajax
  • fancybox
  • fancybox-2
  • 2012-12-05 42 views 0 likes 
    0

    我試圖做這種方式卻得到了零個結果發送iframe輸入值父:如何使用的fancybox標題

    $(".fancybox-html").fancybox({ 
        type    : 'iframe', 
        beforeLoad: function() { 
         this.title = '<li onclick="parent.sendIframeDataToParent(document.getElementsByName(&quot;sector&quot;), &quot;sector_hook&quot;);">Submit</li>' 
        } 
    }); 
    

    ,這是在iframe中輸入代碼:

    <input type="checkbox" id="contact" name="sector" value="cellular"> 
    

    我錯過了什麼嗎?

    +0

    我聞到*同源策略* –

    +0

    我如何訪問iframe dom? 這不返回任何內容: var chk = []; (){(input:checkbox:checked「)。each(function(){ chk.push($(this).val()); }); – DjangoPy

    回答

    0

    試試這個:

    $(".fancybox-html").fancybox({ 
         type : 'iframe', 
         beforeShow : function(){ 
         contactChecked = $('.fancybox-iframe').contents().find('#contact').is(':checked'); 
        }, 
         afterClose: function(){ 
         // The checkbox state is now available in the parent to do with as you wish 
         alert(contactChecked); 
        } 
    }); 
    

    注:這隻會與Fancybox2工作。

    相關問題