473,396 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

smooth scrolling of div element

heello,

i havee one div element in my site with several anchors, that i link to.
to change from anchor to another id like to have a smooth scrolling effect.
all the smooth scrolling effects i could finde onlinee where to generall change all the links on the webpage and where quite overloaded. so i trieed to do something on my own. ther ist no error coming from firefox, but it doesent work also. maybe someonee can help me with this.
heres the function ive written:
Expand|Select|Wrap|Line Numbers
  1. function smoothScrolling(ScrollElement,AnchorElement)
  2. {
  3.     var x = 5;
  4.     var SE = document.getElementById(ScrollElement).scrollTop;
  5.     var AE = document.getElementById(AnchorElement).offsetTop;
  6.  
  7.     if(SE > AE)
  8.         for(i=SE;i<=(AE-8);i=i+1)
  9.         {
  10.             setTimeout("SE = i;",x);
  11.             x = x+5;
  12.         }
  13.     else
  14.         for(i=SE;i>=(AE-8);i=i-1)
  15.         {
  16.             setTimeout("SE = i;",x);
  17.             x = x+5;
  18.         }
  19. }
so actually its only a loop with a increasing timout setting in positioning the site one point by another towards the new anchor.

if anybody has a idea, what the problem about theis code, please let me know - that would be great.

all the best
trom
Dec 16 '07 #1
1 3087
acoder
16,027 Expert Mod 8TB
You're only setting the variable SE, not the actual scrollTop property.
Dec 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
6
by: Jon Paal | last post by:
an excellent working solution for scrolling tables appears at this link http://www.litotes.demon.co.uk/example_scripts/tableScroll.html author has no contact page, but I have a question about...
0
by: The Confessor | last post by:
I've narrowed down my problem, but I've yet to find a solution, so here goes again: Private Sub Form_Main_KeyDown() Handles MyBase.KeyDown Dim PaintEventArgument As New PaintEventArgs...
4
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can...
0
by: Barry L. Camp | last post by:
I've searched for this online but have not found the code I need. I'd like to be able to programatically set a RichTextBox (VB 2005 - Windows Forms app) to scroll one line of text at a time,...
0
by: evan | last post by:
Hi, Pleeeeeaaaassseee help. I have spent literally days looking for a solution to this problem but cannot find the solution. Does anyone know how to smooth scroll a listbox? I can scroll using...
1
by: Bishman | last post by:
Hi, I have been trying to get text to scroll smoothly accross a windows form using GDI+ and a timer. Changing the position of the text by a configurable amount and calling invalidate to force a...
0
by: LostInMd | last post by:
Hi All, I've got an owner drawn listBox where I draw and measure the items that I add to the listBox. For example, I have a listBox that can only display 10 characters on each horizontal line. ...
10
VietPP
by: VietPP | last post by:
Hi all, I'm using ComponentOne FlexGrid for VB.NET to display my data. To create a auto scrollbar using a timer object as: Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.