//打開一個(gè)鏈接
window.open("www.baidu.com", "_self");
//清空頁(yè)面,并寫入東西
document.write("<p></p>");
window.navigator.userAgent
window.location = "www.baidu.com";
js制作側(cè)邊欄(跟隨滾動(dòng))
window.resize = window.onload = window.onscroll = function() {
var oDiv = document.getElementById("div1");
//可視區(qū)頂部距離網(wǎng)頁(yè)頂部的距離
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
//(可視區(qū)的高度 - 物體本身高度)/2
var t = (document.documentElement.clientHeight - oDiv.offsetHeight)/2;
//需要設(shè)置oDive 的position為absolute
oDiv.style.top = scrollTop + t +'px';
}
//此時(shí)拖動(dòng)的時(shí)候有抖動(dòng)現(xiàn)象
//設(shè)置position:fixed --> ie6不支持此固定定位
回到頂部按鈕
window.load = function() {
var timer = null;
var bSys = true;
windwo.onscroll = function() {
if(!bSys) {
clearinterval(timer);
}
bSys = false;
}
var oBtn = document.getElementById("btn1");
oBtn.onclick = function() {
timer = setInterval(function(){
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var iSpeed = Math.floor(-scrollTop / 8);
if(scrollTop == 0) {
clearInterval(timer);
}
//系統(tǒng)滾動(dòng)
bSys = true;
document.documentElement.scrollTop= document.body.scrollTop = scrollTop + iSpeed;
}, 30);
}
window.onscroll
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。