window.onscroll = function () {
var height = getHeight() var menu = document.getElementById("third-menu") var h = document.getElementsByTagName("h2"); var h0 = h[0].offsetTop if(height > h0 - 70) { var num = height -h0 +70 menu.style.marginTop = num + "px" } else { menu.style.marginTop = 0; } clear() for(var i=h.length-1;i>=0;i--) { if(height + 111 > h[i].offsetTop) { var list = document.getElementsByClassName("third-menu-item") list[i].style.color = "blue" break } }
}
function setMenu() {
var height = getHeight() var menu = document.getElementById("third-menu") var h = document.getElementsByTagName("h2"); if(height > 100) { var num = height -100 menu.style.marginTop = num + "px" } else { menu.style.marginTop = 0; } clear() for(var i=h.length-1;i>=0;i--) { if(height + 111 > h[i].offsetTop) { var list = document.getElementsByClassName("third-menu-item") list[i].style.color = "blue" break } }
}
function clear() {
var list = document.getElementsByClassName("third-menu-item") for(let i of list){ i.style.color = "black" }
}
function getHeight() {
var yScroll if (self.pageYOffset) { yScroll = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict yScroll = document.documentElement.scrollTop; } else if (document.body) {// all other Explorers yScroll = document.body.scrollTop; } return yScroll;
} function setHeight(top) {
// if (self.pageYOffset) { // self.pageYOffset = Number(top); // console.log(1) // setMenu() // } if (document.documentElement) { // Explorer 6 Strict document.documentElement.scrollTop = Number(top); console.log(document.documentElement.scrollTop) setMenu() } else if (document.body) {// all other Explorers document.body.scrollTop = Number(top); console.log(3) setMenu() }
} function jump(num) {
var h = document.getElementsByTagName("h2"); for(var i=1;i<=h.length;i++) { if(i == num) { setHeight(h[i-1].offsetTop - 110) break; } }
} function toTop() {
// console.log("aaa") setHeight(0);
} function resize(num) {
var a = document.getElementById("detail") var b = document.getElementById("third-box") var leftLength = a.offsetLeft var sum = leftLength - 50 - num console.log(leftLength) b.style.display = "block" if (sum<0) { b.style.display = "none" } else{ b.style.left = sum + "px" }
}