最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - iPhone YouTube embed with iframe - Stack Overflow

programmeradmin1浏览0评论

Any idea why no matter what height i assign to the iframe, it doesn't resize? I'm testing this on an iPhone (on desktop browser it resizes correctly).

<iframe width="320" height="180" src="" frameborder="0"></iframe>

Any idea why no matter what height i assign to the iframe, it doesn't resize? I'm testing this on an iPhone (on desktop browser it resizes correctly).

<iframe width="320" height="180" src="http://www.youtube./embed/wwbKu0mznf4" frameborder="0"></iframe>
Share Improve this question edited Apr 3, 2011 at 13:18 Black Frog 11.7k1 gold badge37 silver badges66 bronze badges asked Apr 3, 2011 at 11:50 deniciodenicio 5621 gold badge7 silver badges22 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

Try adding scrolling="no".

<iframe scrolling="no" src="..." width="320" height="180"></iframe>

When you rewrite the height with javascript use a %. Not sure why but it seems to be the only thing that works. A good number to start with is height="20%"

Here is what I've been using.

/* patch Ipad Youtube */ 
var agent = navigator.userAgent.toLowerCase(); 
var patchApple = (agent.indexOf('iphone')!=-1) || (agent.indexOf('ipad')!=-1);

if (patchApple) { $('iframe').css({ 'height':'20%' }); }

iPhone doesn't support iframe height attribute. Try putting the iFrame in a div like this:

.scroll {
  height:200px;
  width:200px;
  overflow:auto;
}


<div class="scroll">content</div>
发布评论

评论列表(0)

  1. 暂无评论