我使用谷歌pubads http://development-client-server.com/ds/這是偉大的,直到你到達實際的故事頁面(見http://development-client-server.com/ds/speech-more-common-autism/),當右上邊欄廣告將加載,然後迅速消失。谷歌pubads出現,然後消失
我已經縮小到了stickySidebars函數,我用它來粘貼左側的社交媒體欄和右側的職位列表div(在Google廣告的下面)。但是,粘性功能應該不會影響Google廣告呢?
這裏的JS功能我用,我已經重寫好幾次(並試圖說服客戶使用出來已經是)。
<script>
// Sticky Sidebars
function stickySidebars() {
var length = $('.post-content').height() - $('article .sharing-links').height() + $('.post-content').offset().top;
var lengthSidebar = $('.sticky-container').height() - $('aside .job-listings').height() + $('.sticky-container').offset().top -30;
$(window).scroll(function() {
// Sharing Links
var scroll = $(this).scrollTop() + 90;
var height = $('article .sharing-links').height() + 'px';
if (scroll < $('.post-content').offset().top) {
$('article .sharing-links').css({
'position': 'absolute',
'top': 'auto',
'bottom': 'auto'
});
} else if (scroll > length) {
$('article .sharing-links').css({
'position': 'absolute',
'bottom': '0',
'top': 'auto'
});
} else {
$('article .sharing-links').css({
'position': 'fixed',
'top': '90px',
'height': height
});
}
// Sidebar
var heightSidebar = $('aside .job-listings').height() + 'px';
if (scroll < $('aside .job-listings').offset().top) {
$('aside .job-listings').css({
'position': 'absolute',
'top': '300px',
'bottom': 'auto'
});
} else if (scroll > lengthSidebar) {
$('aside .job-listings').css({
'position': 'absolute',
'bottom': '30px',
'top': 'auto'
});
} else {
if (scroll < $('.sticky-container').offset().top + 300) {
$('aside .job-listings').css({
'position': 'absolute',
'top': '300px',
'bottom': 'auto'
});
} else {
$('aside .job-listings').css({
'position': 'fixed',
'top': '90px',
'height': heightSidebar
});
}
}
});
}
$(window).on('load',function(){
if($(window).width() > 1100){
stickySidebars();
}
});
$(window).resize(function() {
if($(window).width() > 1100){
stickySidebars();
}
});
</script>
所以只是爲了確認:當你註釋掉/刪除'stickySidebars()'的廣告顯示爲預期? – tw16
哦地獄 - 它在我移除stickySidebars()時確實有效。現在它不。 –