谷歌广告没有出现在IE8中
Google Ads not showing up in IE8
我遇到了一个奇怪的问题,谷歌广告(DFP)没有出现在IE8上(没有测试低于8的IE)。
我正在使用以下代码(jQuery正在使用中)。
/*-- Advertizing --*/
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function(){
var script = $('<{0}></{0}>'.format('script'));
script.attr('type','text/javascript');
script.attr('async','async');
script.attr('src',document.location.protocol + '//www.googletagservices.com/tag/js/gpt.js');
$('head').eq(0).prepend(script);
googletag.cmd.push(function() {
googletag.defineSlot('/1016203/PG_194x662_Async', [194, 662], 'div-gpt-ad-1320434986666-0').addService(googletag.pubads());
googletag.defineSlot('/1016203/PG_530x99_Async', [530, 99], 'div-gpt-ad-1320435053303-0').addService(googletag.pubads());
googletag.defineSlot('/1016203/PG_530x50_Async', [530, 50], 'div-gpt-ad-1320435026691-0').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
googletag.cmd.push(function () { googletag.display('div-gpt-ad-1320434986666-0'); });
googletag.cmd.push(function () { googletag.display('div-gpt-ad-1320435053303-0'); });
googletag.cmd.push(function () { googletag.display('div-gpt-ad-1320435026691-0'); });
}());
这是经过测试的,并且在IE9、Chrome、Firefox中正常工作。。。但IE8是唯一的例外。该网站位于photogallery.classiccars.com上。(从DOM树上)看起来,一个IFrame在IE8中部分加载,但只是退出了。
Google的代码使用for (var x in array)
,当Array.prototype扩展时,它在某些浏览器中会出现问题。
我无法理解他们为什么不使用.length属性进行迭代,或者检查hasOwnProperty,但这似乎是眼前的问题。
由于Backbone.js包含在该项目中,该项目需要Undercore.js,因此我正在调整代码库,以便为该项目使用Underscore.js中的实用程序方法。
//instead of an ES5-Shim extension to Array.prototype.filter (for example)
var ary = [...];
//instead of this...
var results = ary.filter(function(item){...}); //es5
//use this
var results = _.filter(ary, function(item){...}); //underscore.js
请注意,任何编写JavaScript的人都应避免使用for。。除非显式检查hasOwnProperty。这适用于数组和对象。
var ary = [...];
for (var x in ary) {
if (!ary.hasOwnProperty(x)) continue; //skip inherited properties.
//your handling here
...
}
相关文章:
- 谷歌地图固定位置覆盖
- 不显示带有本地json文件数据的谷歌地图脚本
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- 谷歌放置API:按国家或餐馆名称搜索餐馆
- 谷歌地图v3标记没有显示ie8和9
- 谷歌图表-“;快速入门Hello World;不在IE8中渲染
- IE8谷歌可视化权限被拒绝
- 谷歌地图集群IE8问题
- IE8谷歌地图错误
- 在 https 上使用谷歌地图时,如何避免 IE8 中的安全警告
- 谷歌图表适用于IE7,但不适用于IE8或IE9
- 是什么导致了IE8中的谷歌地图错误
- 谷歌地图,“是空或不是对象”和IE8
- 谷歌广告没有出现在IE8中
- IE8中缺少谷歌标记
- 神秘的谷歌翻译错误在IE8
- 谷歌图表未在IE8中呈现
- 使用谷歌地图的IE8中的错误“;undefined为null或不是对象”;
- IE8上的谷歌图表重绘功能错误
- IE8的谷歌地图.setmap问题