Line 74: | Line 74: | ||
if (document.documentElement) { // Explorer 6 Strict | if (document.documentElement) { // Explorer 6 Strict | ||
document.documentElement.scrollTop = Number(top); | document.documentElement.scrollTop = Number(top); | ||
− | console.log( | + | console.log(document.documentElement.scrollTop) |
setMenu() | setMenu() | ||
} | } | ||
Line 84: | Line 84: | ||
} | } | ||
function jump(num) { | function jump(num) { | ||
− | |||
var h = document.getElementsByTagName("h2"); | var h = document.getElementsByTagName("h2"); | ||
for(var i=1;i<=h.length;i++) | for(var i=1;i<=h.length;i++) | ||
Line 90: | Line 89: | ||
if(i == num) | if(i == num) | ||
{ | { | ||
− | |||
− | |||
setHeight(h[i-1].offsetTop - 110) | setHeight(h[i-1].offsetTop - 110) | ||
break; | break; |
Revision as of 18:27, 17 October 2018
window.onscroll = function () {
var height = getHeight() var menu = document.getElementById("third-menu") var h = document.getElementsByTagName("h2"); console.log(h[0].offsetTop) 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 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" }
}