#10101 closed bug (invalid)
scrollTop in iFrame always returns 0
Reported by: | anonymous | Owned by: | anonymous |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | offset | Version: | 1.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Using $(window).scrollTop() in iFrame always returns 0.
To reproduce, load an iFrame from a secondary page. In the iFrame page, specify a scroll event that uses $(window).scrollTop(). You'll notice it always returns 0.
Using document.documentElement.scrollTop or document.body.scrollTop returns the correct value.
Change History (8)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → offset |
---|---|
Owner: | set to anonymous |
Status: | new → pending |
Try this:
$("body").scrollTop()
comment:3 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!
comment:4 Changed 11 years ago by
I can confirm this still happens with jQuery 1.7.2 with IE 8, and using $("body").scrollTop() also provides a zero regardless of actual scroll position.
comment:5 Changed 11 years ago by
Why is it that nobody can produce a test case?
jsFiddle runs its test in an iframe.
worksforme in IE8, so please provide one that doesn't.
comment:6 Changed 11 years ago by
At the time, I didn't produce a test case because I was busy fixing the issue and moving on to the rest of my work. At this point, partly because some other change I made to my HTML appears to have fixed it with $(window).scrollTop(), although $("body").scrollTop() remains an issue, and partly because jsfiddle doesn't like it when I try to put frames inside of its frames, making it difficult to reproduce the problem there.
As far as with $("body").scrollTop(), I posted an example as a gist on GitHub here:
https://gist.github.com/3137546
This gives me correct values for $("body").scrollTop() in Chrome 20.0 and Safari 5.1.7, zero in IE 8; I don't have access to firefox at the moment. If I can figure out how I had the issue with $(window).scrollTop(), I'll post a second gist for it.
comment:7 follow-up: 8 Changed 9 years ago by
I'm seeing this problem in Chrome 32.0.1700.77 on Mac OSX. The suggested solution [$("body").scrollTop()] also yields zero.
comment:8 Changed 9 years ago by
Please disregard this. I forgot that we are using an old version of jQuery (viz., v. 1.7.2).
I forgot to specify that this problem only occurs in IE.