如何告诉 iframe 将图像链接调整为给定的宽度和高度

How to tell iframe to resize the image link to a given width and height

本文关键字:高度 iframe 何告诉 图像 调整 链接      更新时间:2023-09-26

我有 1 个 iframe 并且有 youtube 链接,但我还需要显示相同的 iframe 图像。一旦我传递了带有宽度和高度的图像链接,它就不会调整大小。

怎么做?

目录:

<iframe width="257" 
        height="194" 
        src="http://www.youtube.com/embed/adadfad" 
        frameborder="0" 
        allowfullscreen=""></iframe>

j查询:

    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'});
});

如果你想调整图像的大小,你可以使用普通的jquery。

$('img').css('width','300px');
     $('img').css('height','300px');