【问题标题】:get the meta data from an advert iframe从广告 iframe 中获取元数据
【发布时间】:2017-04-15 00:59:01
【问题描述】:

我想以与 Google 展示类似的方式在我的网站上投放广告。我正在使用 iframe 插入广告,但我遇到了大小问题。

我不知道为什么 iframe 默认大小为 300 x 150,无论源大小如何。

广告有一条带有尺寸的元线。

<meta name="ad.size" content="width=300,height=250">

我想获取此信息并使用 javascript 更改 iframe 大小。我试过了:

$('#myiframe').load(function() {
        var element = document.querySelector('meta[name="ad.size"]')['content‌​'];
});     

结果为空。

请你帮忙。

B/R

【问题讨论】:

    标签: javascript iframe meta


    【解决方案1】:

    好的,我终于明白了:

    var adif= document.getElementById('myiframe');
    var x= adif.contentWindow.document.getElementsByName("ad.size")[0].content; 
    

    我希望它可以帮助别人。

    【讨论】:

      猜你喜欢
      • 2015-11-12
      • 1970-01-01
      • 1970-01-01
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      • 2017-02-17
      • 2010-11-08
      相关资源
      最近更新 更多