Side navigation
#10101 closed bug (invalid)
Opened August 19, 2011 11:34PM UTC
Closed September 04, 2011 08:01AM UTC
Last modified January 24, 2014 10:08PM UTC
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.
Attachments (0)
Change History (8)
Changed August 19, 2011 11:35PM UTC by comment:1
Changed August 20, 2011 02:16PM UTC by comment:2
component: | unfiled → offset |
---|---|
owner: | → anonymous |
status: | new → pending |
Try this:
$("body").scrollTop()
Changed September 04, 2011 08:01AM UTC by comment:3
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!
Changed July 10, 2012 09:21PM UTC by comment:4
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.
Changed July 10, 2012 09:52PM UTC by comment:5
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.
Changed July 18, 2012 05:21PM UTC by comment:6
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.
Changed January 24, 2014 10:05PM UTC by comment:7
I'm seeing this problem in Chrome 32.0.1700.77 on Mac OSX. The suggested solution [$("body").scrollTop()] also yields zero.
Changed January 24, 2014 10:08PM UTC by comment:8
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.