SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: scrollTop
-
May 31, 2007, 12:28 #1
scrollTop
Hi,
I feel like an idiot, but I can't seem to figure out how to use this property. From my understanding the scrollTop property is supposed to return an integer representing how far the object has been scrolled from the top of the window?
Here is my code:
Code:<html> <body> fsdfsd <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <div style="height: 100px; width: 100px; overflow: scroll;" onclick="alert(this.scrollTop)"> 0123456789 0123456789 0123456789 0123456789 0123456789 0123456789 </div> <br /> <br /> <br /> <br /> </body> </html>
yeah not the most compliant code, but I was just testing it...but anyways, no matter what happens the scrollTop property always returns 0. I don't understand why.
Any help would be appreciated.
-
May 31, 2007, 14:12 #2
- Join Date
- Mar 2005
- Location
- USA
- Posts
- 5,482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Put more content in the <div>, since you are referring to the <div>'s scrollTop property.
Not including the doctype can cause things to act differently, especially in IE. You should always use valid code for testing things.We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.
-
May 31, 2007, 14:49 #3
Thanks for pointing out what was wrong.
The reason I am doing this is because I have an iframe which has an anchor link in it, and when the link is clicked the causes BOTH the iframe AND parent page to scroll to the top link. And I wanted to like make it so that the parent page then scrolls back to its original position.
Do you have any idea how I could tackle this?
-
May 31, 2007, 23:03 #4
- Join Date
- Mar 2005
- Location
- USA
- Posts
- 5,482
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Perhaps you should try fixing the cause instead of the symptom.
Is the link something like this?
Code:<a href="#" onclick="doSomething();">do something</a>
We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.
-
Jun 1, 2007, 11:51 #5
Hmm...the problem is I don't have control of the website inside of the iFrame...
So whatever the anchor link does is out of my control. I've been trying to find a way around this.
Bookmarks