$.support.cors = true; //load config var configInfo = config[4]; if(!$.cookie('dspUid')){ var dspUid = new Date().getTime() + Math.random()*100000 | 0; $.cookie('dspUid', dspUid, {expires: 300, path: '/'}); } function getSystem () { var sUserAgent = navigator.userAgent; var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows"); var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel"); if (isMac) return "Mac"; var isUnix = (navigator.platform == "X11") && !isWin && !isMac; if (isUnix) return "Unix"; var isLinux = (String(navigator.platform).indexOf("Linux") > -1); if (isLinux) return "Linux"; if (isWin) { var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1; if (isWin2K) return "Win2000"; var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1; if (isWinXP) return "WinXP"; var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1; if (isWin2003) return "Win2003"; var isWinVista= sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1; if (isWinVista) return "WinVista"; var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1; if (isWin7) return "Win7"; var isWin10 = sUserAgent.indexOf("Windows NT 10") > -1 || sUserAgent.indexOf("Windows 10") > -1; if (isWin10) return "Win10"; } return "other"; }; var configObj = { url : 'http://pcsoftwords.dftoutiao.com/dfpcitv/pcitv', params :{ type:'toutiao', newsitetype:'zhanmeng', qid:'03871', uid:$.cookie('dspUid'), os: getSystem(), pageposition:'ny', thisurl:location.href, jsonpcallback:'loadDspAd' } }; $.ajax({url: configObj.url, type: 'get', dataType: 'jsonp', jsonp: 'jsonp',timeout: 1000, data:configObj.params,jsonpCallback:'loadDspAd', success:function (e) {}, error:function (e) {loadBase()}}); function loadDspAd(e){ if(e.data && e.data.length >0){ var data = e.data[0]; $('.container').append('广告'); $('.image-wrapper > img')[0].src = data.miniimg[0].src; $('.image-wrapper')[0].href = data.url; document.getElementById("ak").onload=function(){ var page_size ="304,"+document.getElementById('ak').offsetHeight; $('head').append(''); if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') { window.external.CppCall(page_size); } }; // 渲染 uploadUrl(data.showbackurls[0]); //进入可视区s域上报 if(data.isinviewbackurl){ uploadUrl(data.inviewbackurls[0]); } //关闭上报 $('.close').on('click',function () { uploadUrl(data.closebackurls[0]) }); //点击上报 $('.image-wrapper').on('click',function () { uploadUrl(data.clickbackurls[0]) }) }else{ loadBase() } }; //加载打底 function loadBase(){ $('.container').append('广告'); document.getElementById("ak").onload=function(){ var page_size ='304,'+document.getElementById('ak').offsetHeight; $('head').append(''); if (typeof window.external != 'undefined' && typeof window.external.CppCall != 'undefined') { window.external.CppCall(page_size); } }; } //上报 function uploadUrl(url) {var images = new Image();images.src = url;}