超過左欄高,左欄寬變小,再上拉寬又比加載時大,用審查檢查發現當超過sideHeight高,cssText“替換”了左欄CSS屬性為fixed;right:0;top:-1609。再上拉由于else里只是“更改”position屬性,所以遺留了 right;top屬性導致的
方案:if與else后跟的語句都運用cssText進行替換
if是style.cssText='width:33%;position:fixed;right:0;top:'+(-(sideHeight-screenHeight))+'px'
else是style.cssText='width:33%;float:right'
方案:if與else后跟的語句都運用cssText進行替換
if是style.cssText='width:33%;position:fixed;right:0;top:'+(-(sideHeight-screenHeight))+'px'
else是style.cssText='width:33%;float:right'
2017-03-18
右側邊欄滾動到媽媽專場-寬度按出現跳動的解決:
if(scrollHeight+screenHeight>sideHeight){
//右側邊欄的高度-右側邊欄可視區域的高度
domSider.style.position="fixed";
domSider.style.right=0+'px';
domSider.style.top=-(sideHeight-screenHeight)+'px';
}else{
//設為默認值
domSider.style.position='static';
}
if(scrollHeight+screenHeight>sideHeight){
//右側邊欄的高度-右側邊欄可視區域的高度
domSider.style.position="fixed";
domSider.style.right=0+'px';
domSider.style.top=-(sideHeight-screenHeight)+'px';
}else{
//設為默認值
domSider.style.position='static';
}
2017-03-01
raw JavaScript沒有處理跨瀏覽器的函數,所以手寫了一個addEvent事件,但是感覺少了一點var addEvent = function (obj, event, fn) {
if (obj.addEventListener) {obj.addEventListener(event, fn, false);//DOM2級事件處理
} else if (obj.attachEvent) {obj.attachEvent('on' + event, fn);//IE事件處理
} else {obj['on' + event] = fn;//DOM 0級事件處理
}
};詳見高設3rd
if (obj.addEventListener) {obj.addEventListener(event, fn, false);//DOM2級事件處理
} else if (obj.attachEvent) {obj.attachEvent('on' + event, fn);//IE事件處理
} else {obj['on' + event] = fn;//DOM 0級事件處理
}
};詳見高設3rd
2016-12-30