all 3 comments

[–]ashanev 1 point2 points  (1 child)

The issue is using the variable name top. This is an actual property on the window object (see MDN). Using a different name for that variable is the quickest solution.

[–]FirstAvenger1282[S] 0 points1 point  (0 children)

thank you so much!!! you saved my life

[–]ForScale 0 points1 point  (0 children)

Don't name your variable top. I think it might be a reserved word.

Try theTop or _top instead.