473,748 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Alternative "scrollIntoView "

Hi friends,

I found a problem while "scrolling into view" and to overcome this I
made a function to simulate javascript's function. I would like to
share it and here it is:

function alternativeScro llIntoView(pare ntDiv,elementIn toDiv)
{
var principal =parentDiv;
principal.scrol lTop = 0;
var rects = principal.getCl ientRects()[0];
var topFinal = rects.top;
var bottomFinal = rects.bottom;
var bottomActual = elementIntoDiv. getClientRects( )[0].bottom;
if (bottomActual == 0)
{
return;
}
while(bottomAct ual>bottomFinal ||bottomActual< topFinal)
{
var direction="down ";
if(bottomActual <topFinal) direction="up";
principal.doScr oll(direction);
bottomActual=el ementIntoDiv.ge tClientRects()[0].bottom;
}
}

It worked in my enviroment, i hope it could be useful for you too.

Xevi.

PS: It was done for IE. I didn't test it in other enviroments.

Dec 30 '05 #1
4 15431
xe************@ gmail.com wrote:
Hi friends,

I found a problem while "scrolling into view" and to overcome this I
made a function to simulate javascript's function. I would like to
share it and here it is:


What version of IE supports getClientRects( ) and doScroll() but not
scrollIntoView( )? Doesn't scrollIntoView( ) go back to IE 4 and the
other two to IE 5?
[...]
--
Rob
Dec 30 '05 #2
All of these functions worked on IE5.5 but the result was not always
the expected. Sometimes the element didn't fit into the view. That's
why we made this function to overcome this.

Dec 30 '05 #3
xe************@ gmail.com wrote:
All of these functions worked on IE5.5 but the result was not always
the expected. Sometimes the element didn't fit into the view. That's
why we made this function to overcome this.


A more cross-browser function could use scrollIntoView first, then
adjust the position using your function if the features are supported
(of course scrollIntoView should be feature tested too).

That may also provide some extra speed/efficiency on IE where the
element needs to scroll a long way.
--
Rob
Dec 30 '05 #4
You're right, I agree that this is the best option. Better use first
what the enviroment provides and if necessary use the function I made.

Thanks a lot.

Dec 30 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3433
by: John Geddes | last post by:
Has anyone come up with an "IsInview" function that one could use to test whether scrollIntoView is needed? Imagine a (scrolled) list of editable item prices. I want to impose maximum and minimum limits - so I test the just-changed value when the user either starts to edit another field, or tries to close the form. If there is an error, I need to highlight the error - and that means scrolling back to the problem item if it is not in...
5
13378
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
8995
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9381
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9332
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8252
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
3316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.