Adsense(250x250)的Iframe自动将同一页面上Youtube的Iframe大小调整为250x250
同一页面(www.goo.gl/xLAhN)在iframe中嵌入了一个尺寸为640x390的youtube视频,使用以下代码:(尝试了3种youtube嵌入代码,所有结果都相同)Adsense(250x250)的Iframe自动将同一页面上Youtube的Iframe大小调整为250x250,iframe,youtube,cross-domain,adsense,Iframe,Youtube,Cross Domain,Adsense,同一页面(www.goo.gl/xLAhN)在iframe中嵌入了一个尺寸为640x390的youtube视频,使用以下代码:(尝试了3种youtube嵌入代码,所有结果都相同) `` 同一页面中有一个Adsense横幅嵌入在iframe中的250x250中,代码如下: `<script type="text/javascript"><!-- google_ad_client = "ca-pub-xxxxxxxxxxxxx"; /* test */ google_ad_slo
``
同一页面中有一个Adsense横幅嵌入在iframe中的250x250中,代码如下:
`<script type="text/javascript"><!--
google_ad_client = "ca-pub-xxxxxxxxxxxxx";
/* test */
google_ad_slot = "xxxxxxx";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>`
`
`
youtube视频的100%显示时间为250x250。查看视图源代码,Youtube iframe现在使用250x250指令附加了一个样式元素
`<iframe id="player" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/GxTl1Ykbuww?enablejsapi=1&origin=origin-domain.com" frameborder="0" style="width: 250px; height: 250px;"></iframe>`
`
如果删除adsense代码,youtube视频将以正确的大小加载
请帮助,5天后我认为这与CORS有关,但网上没有关于这个问题的任何信息。不知何故,adsense被允许克服跨域限制,并将youtube iframe注入其自身大小。问题与jquery有关,jquery是美化iframe主题的一部分
var win = jQuery(window),
iframes = jQuery('iframe:not(.slideshow iframe):not( iframe.no_resize)',container),
adjust_iframes = function() {
iframes.each(function() {
var iframe = jQuery(this),frame_parent_w = iframe.parent().width(),proportions = 16/9;
if(this.width && this.height) {
proportions = Math.round(this.width / this.height * 1000) / 1000;
iframes.css({
width:frame_parent_w,height: frame_parent_w / proportions});
}
});
};
adjust_iframes();
win.smartresize(adjust_iframes);
在我将:not(在iframe内部)添加到第二行之后(因为Adsense总是将其iframe包装在内部标记中,使用上面的代码忽略Adsense iframe设置,所有内容都按预期呈现
var win = jQuery(window),
iframes = jQuery('iframe:not(.slideshow iframe):not( iframe.no_resize)',container),
adjust_iframes = function() {
iframes.each(function() {
var iframe = jQuery(this),frame_parent_w = iframe.parent().width(),proportions = 16/9;
if(this.width && this.height) {
proportions = Math.round(this.width / this.height * 1000) / 1000;
iframes.css({
width:frame_parent_w,height: frame_parent_w / proportions});
}
});
};
adjust_iframes();
win.smartresize(adjust_iframes);