1

Here is a JavaScript. This is working good in chrome but not working in Firefox and IE when it is inside blogger

if (document.body.scrollTop > 5) {
          var header = document.getElementsByClassName("header")[0];
          header.className = "header down"
}

and i have also trie it

if (document.getElementsByTagName('body')[0].scrollTop > 5) {
          var header = document.getElementsByClassName("header")[0];
          header.className = "header down"
        }

Please tell how it will work in Firefox and IE. Please only JavaScript and No J Query.

Syed Muhammad Asad
  • 208
  • 1
  • 2
  • 13

1 Answers1

4

I've had a look at your website javascript and can see that in IE and Firefox, document.body.scrollTop is always 0. See document.body.scrollTop is always 0 in IE even when scrolling.

Therefore, down will never get added to your header div. You will need to use a combination of document.body.scrollTop or document.documentElement.scrollTop depending on the browser in use.

Community
  • 1
  • 1
Sam
  • 893
  • 8
  • 21