我有 1 个 iframe 和 youtube 链接,但我还需要显示相同的 iframe 图片。一旦我传递具有宽度和高度的图像链接,它就不会调整大小。
怎么做?
HTML:
<iframe width="257"
height="194"
src="http://www.youtube.com/embed/adadfad"
frameborder="0"
allowfullscreen=""></iframe>
jQuery:
divID.find('iframe').attr('src', function(i, val) {
return
"<img src=http://img.youtube.com/vi/" +
match[2] +
"/2.jpg width=300 height=200/>"
});
最佳答案
这有效。
root.find('iframe').ready(function(){
root.find('iframe')
.contents()
.find('body')
.html("<img src=http://img.youtube.com/vi/" + match[2] + "/2.jpg />");
root.find('iframe')
.contents()
.find('img')
.css({'width':'225px', 'height':'175px'});
});
关于javascript - 如何告诉 iframe 将图像链接调整为给定的宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11342092/