亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

邊欄高度:offsetHeight的高度為空,取不到值是為什么?

var $ = function(id){

return document.getElementById(id);

}


var addEvent = function(obj,event,fn){

? ? if(obj.addEventListener){

? ? obj.addEventListener(event,fn,false);

? ? }else if(obj.attachEvent){

? ? obj.attachEvent('on'+event,fn);

? ? }

}

var domSider = $('J_BdSide');

var scrollEvent = function(){

var sideHeight = domSider.offsetHeight;

var screenHeight = document.documentElement.clientHeight||document.body.clientHeight;

var scrollHeight = document.documentElement.scrollTop||document.body.scrollTop;

if(scrollHeight+screenHeight>sideHeight){

domSider.style.cssText = 'position:fixed;right:0px;top:'+(-(sideHeight-screenHeight))+'px';

}else{

domSider.style.position='static';

}

}

addEvent(window,'scroll',function(){

scrollEvent();

});

addEvent(window,'resize',function(){

scrollEvent();

});


正在回答

舉報

0/150
提交
取消

邊欄高度:offsetHeight的高度為空,取不到值是為什么?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號