如何在iframe中引用iframe [英] how to refer iframe within iframe
本文介绍了如何在iframe中引用iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要引用位于另一个iframe中的iframe
I want to refer iframe which is inside another iframe
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="playButton">Play</div>
<div class="flex-active-slide">
<iframe src=""> <!--But refering this-->
#document
<html>
<body>
<iframe src=""><!--want to refer this iframe -->
#document
<html>
<body>
</body>
</html>
</iframe>
</body>
</html>
<iframe>
</div>
jQuery(document).ready(function($){
$(".playButton").on('click',function(){
$(".flex-active-slide iframe")[0].src += "&autoplay=1";
});
});
推荐答案
Use contents()
to get inside first frame window once it has loaded:
$('iframe').on('load', function(){
var $secondFrame = $(this).contents().find('iframe');
$secondFrame.attr('src', someUrl)
})
这篇关于如何在iframe中引用iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文