iframe子頁面調用父頁面js函數


window.parent.document.getElementById("test").value; 

jQuery方法為: 

$(window.parent.document).contents().find("test").val(); 

 

 

例:

父:

<div id="page-wrapper" class="gray-bg dashbard-1">
<div class="row J_mainContent" id="content-main" class="tab-content">
<iframe id="J_iframe" width="100%" height="100%" src="index_v1.html" frameborder="0" data-id="index_v1.html" seamless></iframe>
</div>
</div>

子方法:
$('.btn-skip').click(function(){
var url = 'index_v5.html';
$(window.parent.document).contents().find("#J_iframe").attr('src', url);
});


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM