javascript - Jump to top of the page link on long pages -


I need an advice about adding "go to top" link to the bottom of the page, but only when the page < / P>

  • Check page height
  • Calculate the footer and top height
  • Compare the size < / Li>
  • Find the last element before the footer (for example ID)
  • Enter the link for the # top-menu

(Pure JavaScript follows Working in IE6 also. L do not want to use the library.)

Hmm ... I body.scrollTop! = 0, it means that the page is more than the browser's viewport. I will always create a "go to top" element on the page, but its visual condition depends on the body.scrollTop! = 0. To find out that body.scrollTop! = 0, you have to vote every 100ms of your value, and if it is zero, set the display property of your "go to top object" in "or" not.

However, "an annoying top" element simply adds to the height of the entire page. In such a case, using 'visibility' property instead of 'display' can be a better option.

EDIT: Just found (possible malware link removed), if you have been given above it may be useful. / P>


Comments