/*
* 图片下追加广告
* */
$(function () {
var _adv = ['65b7c22261d6e2251224f061','65b8b94c61d6e2609142c6f3','65b8b97161d6e2631b795d94','65b8b98f61d6e2686a3d5c24','65b8b9b261d6e2631b795d97'];
var _imgHe = 500;
var preImg = $('pre img');
var _lastTop = 0;
var _showIndex = 0;
for (var i = 0, l = preImg.length; i < l; i++) {
//var imgUrl = preImg[i].src;
//console.log(preImg[i].position().top);
/*var numNow = randomRange(1, 3);
getImageHeight(imgUrl, numNow, function (preImgI, h, numNow) {
if (parseInt(h) > _imgHe && numNow == 1) {
var getAdvT = getAdv(_adv);
var advAd = $("").html(getAdvT);
$('img[src="' + preImgI.src + '"]').after(advAd);
}
})*/
//$('img[src="' + preImgI.src + '"]').after(""+ +"
");
if((i+1)%8 == 0 && _showIndex<=4)
{
$('img[src="' + preImg[i].src + '"]').after("");
_showIndex++;
if(_showIndex >4)
{
break;
}
}
}
$(".img_ad_list a").css({
"color": "#0f6b99",
"font-size": "12px",
"margin": "0",
"padding": "0"
});
});
// 获取广告
function getAdv(_adv) {
for (var ai = 0, al = _adv.length; ai <= al; ai++) {
var index = Math.floor((Math.random() * _adv.length));
return _adv[index]
}
}
//获取图片高度
function getImageHeight(url, numNow, callback) {
var img = new Image();
img.src = url;
// 如果图片被缓存,则直接返回缓存数据
if (img.complete) {
callback(img, img.height, numNow);
} else {
// 完全加载完毕的事件
img.onload = function () {
callback(img, img.height, numNow);
this.οnlοad = null;
}
}
}
function randomRange(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}