重写document.write
iframe 调用广告
Google Adsense在2011年5月也明文禁止了iframe方式的调用,因为放到iframe里的广告很难判断网页内容的相关性,不容易匹配合适的广告,同时,早期也有不少网站主通过iframe放广告的方式进行作弊,产生无效点击,因此Google AdSense就禁止了iframe的调用方式。
但iframe代码存在一部分已知的问题,如下:
1)在系统中修改尺寸无效,需修改线上代码;
2)不支持漂浮与弹窗类型的广告位;
3)广告不支持原窗口打开,已经设置为原窗口打开的广告将在iframe中打开;
4)广告位上投放富媒体类型的广告物料,则无法与主页面的内容进行直接交互;
5)不支持来源域和被访url定位。
优酷:
window.nova_init_hook_ab = function(){ Nova.addScript("http://html.atm.youku.com/html?v=135978183&u=4336697&s=269470&p=78,79,558,747,753,850,616,771&k="+tags); }
function setTaoBao44186YK() { var _yk_hash = ""; //获得分类Id var _yk_hash = ""; if (catId != null && typeof (catId) != "undefined") { _yk_hash += catId.replace(/[^\d]/g, ''); } _yk_hash += ","; //获得二级分类Id if (cateStr != null && typeof (cateStr) != "undefined") { _yk_hash += cateStr.replace(/[^\d\|]/g, ''); } _yk_hash += ","; //获得标签 if (attrs != null && typeof (attrs) != "undefined") { _yk_hash += attrs.replace(/,/g, "|"); } //获得宽窄屏 var _yk_player_thx = ""; if (player_thx != null && typeof (player_thx) != "undefined") { _yk_player_thx = player_thx; } else { _yk_player_thx = "0"; } var youku_ad_iframe_44186 = document.getElementById('youku_ad_iframe_44186'); //player_thx : 默认值为0,代表标屏(4:3); 1 则代表宽屏(16:9) if (_yk_player_thx == "1") { if (youku_ad_iframe_44186) { youku_ad_iframe_44186.src = "http://static.atm.youku.com/sunxin/taobao/20110831/taobaox300x250x20110831.html" + "#" + _yk_hash; } } else { if (youku_ad_iframe_44186) { youku_ad_iframe_44186.src = "http://static.atm.youku.com/Youku2012/201208/0810/taobao/taobao_iframe.html" + "#" + _yk_hash; } } var youku_ad_44186 = document.getElementById('youku_ad_44186'); if (youku_ad_44186) { youku_ad_44186.style.display = ""; } } var ad_44186 = setTimeout(setTaoBao44186YK, 500); function setTaoBao47874YK() { //获得分类Id var _yk_hash = ""; if (catId != null && typeof (catId) != "undefined") { _yk_hash += catId.replace(/[^\d]/g, ''); } _yk_hash += ","; //获得二级分类Id if (cateStr != null && typeof (cateStr) != "undefined") { _yk_hash += cateStr.replace(/[^\d\|]/g, ''); } _yk_hash += ","; //获得标签 if (attrs != null && typeof (attrs) != "undefined") { _yk_hash += attrs.replace(/,/g, "|"); } var youku_ad_iframe_47874 = document.getElementById('youku_ad_iframe_47874'); if (youku_ad_iframe_47874) { youku_ad_iframe_47874.src = "http://static.atm.youku.com/sunxin/20111116/taobaox300x100x20111115new.html" + "#" + _yk_hash; } var youku_ad_47874 = document.getElementById('youku_ad_47874'); if (youku_ad_47874) { youku_ad_47874.style.display = ""; } } var ad_47874 = setTimeout(setTaoBao47874YK, 500); function ad_div_747() { var adcontent = ""; adcontent = adcontent + "<div align=\"center\" style=\"display:block;\"> <iframe align=\"center,center\" width=\"610\" height=\"100\" scrolling=\"no\" frameborder=\"0\" allowtransparency=\"true\" marginheight=\"0\" marginwidth=\"0\" style=\"margin-bottom:15px;display: block;\" src=\"http:\/\/static.atm.youku.com\/Youku2013\/201302\/0221\/22371\/610-100-under.html\"><\/iframe><\/div>"; var obj = document.getElementById('ab_747'); if (!obj || typeof (obj) != 'object' || typeof (adcontent) != 'string') return; if (null != adcontent && 0 == adcontent.length) { obj.style.display = 'none'; } else { obj.style.display = 'block'; if (null != adcontent) { obj.innerHTML = adcontent; } } } ad_div_747(); function ad_div_753() { var adcontent = ""; adcontent = adcontent + "<div id=\"youku_ad_44186\" align=\"center\" class=\"mod\" style=\" 300px; height: 250px; display: none;\"><iframe scrolling=\"no\" id=\"youku_ad_iframe_44186\" style=\" 300px; height: 250px; border: 0pt none;\" height=\"250\" width=\"300\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\"><\/iframe><\/div>"; var obj = document.getElementById('ab_753'); if (!obj || typeof (obj) != 'object' || typeof (adcontent) != 'string') return; if (null != adcontent && 0 == adcontent.length) { obj.style.display = 'none'; } else { obj.style.display = 'block'; if (null != adcontent) { obj.innerHTML = adcontent; } } } ad_div_753(); function ad_div_850() { var adcontent = ""; adcontent = adcontent + "<div align=\"center\" class=\"mod\" id=\"youku_ad_pip_small\" style=\"display:block;\"><iframe style=\"margin:0px;\" scrolling=\"no\" height=\"100\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\" width=\"610\" src=\"http:\/\/static.atm.youku.com\/Youku2013\/201303\/0314\/22371\/middle_20130314.html\"><\/iframe><\/div>"; var obj = document.getElementById('ab_850'); if (!obj || typeof (obj) != 'object' || typeof (adcontent) != 'string') return; if (null != adcontent && 0 == adcontent.length) { obj.style.display = 'none'; } else { obj.style.display = 'block'; if (null != adcontent) { obj.innerHTML = adcontent; } } } ad_div_850(); function ad_div_616() { var adcontent = ""; adcontent = adcontent + "<div id=\"youku_ad_47874\" align=\"center\" class=\"mod\" style=\" 300px; height: 100px; display: none;\"><iframe scrolling=\"no\" id=\"youku_ad_iframe_47874\" style=\" 300px; height: 100px; border: 0pt none;\" height=\"100\" width=\"300\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" border=\"0\"><\/iframe><\/div>"; var obj = document.getElementById('ab_616'); if (!obj || typeof (obj) != 'object' || typeof (adcontent) != 'string') return; if (null != adcontent && 0 == adcontent.length) { obj.style.display = 'none'; } else { obj.style.display = 'block'; if (null != adcontent) { obj.innerHTML = adcontent; } } } ad_div_616();