我想引用另一个iframe中的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";
});
});
答案 0 :(得分:0)
加载后,使用contents()
进入第一帧窗口:
$('iframe').on('load', function(){
var $secondFrame = $(this).contents().find('iframe');
$secondFrame.attr('src', someUrl)
})
答案 1 :(得分:0)
Consider this:
<div class="flex-active-slide">
<iframe class="i1" src=""> <!--But refering this-->
#document
<html>
<body>
<iframe class="i2" src=""><!--want to refer this iframe -->
#document
<html>
<body>
</body>
</html>
</iframe>
</body>
</html>
<iframe>
</div>
您可以使用“i2”类访问iframe:
var l1 = $(".flex-active-slide .i1")[0];
$(l1.contentDocument).find("iframe.i2");