Window.scrollTo Fails Under OVERFLOW-Y: auto Style.
I was trying to subclass a Web Treeview control for my own evil purposes and ran into a sticky problem - scrollTo not working! Just for background, my evil purpose was to replace the Infragistics ultra web tree control, since we only use about 5% of the functionality, but pay the full price of upgrades and page size for the other 95%.
anyway, all was going well, until I tried to implement the ScrollTo functionality.
My first pass looked something like this:
[javascript]
<Script Type="text/javascript">
<!–
var ele = document.getElementById(nodeID);
window.scrollTo(ele.parentElement.offsetParent.offsetLeft ,ele.parentElement.offsetParent.offsetTop);
//–>
</Script>
[/javascript]
Now this worked great in my sample text page, but when I dropped it into the main application page, it didn’t do a damn thing. What gives?
Well, I traced the problem down to a style tag on the wrapping div tag:
[css]
OVERFLOW-Y: auto;
[/css]
It seems that the auto setting disallowed my scrolling to a specific x,y coordinate when that coordinate was outside the visible space.
That really stunk because I didn’t have the ability to modify the existing container page, beyond replacing the Infragistics control tag.
Luckily, I found a workaround:
[javascript]
<Script Type="text/javascript">
<!–
var ele = document.getElementById(nodeID);
ele.scrollIntoView();
//–>
</Script>
[/javascript]
Not only does this work within the CSS overflow directive, but it’s also a bit more elegant since I no longer have to worry about all that parent offset nonsense.
Related Posts - The 3 Most Important Questions You Should Ask About Each Bug You Find. I stumbled upon (quite literally) an article by Tom Van Vleck titled Three Questions About Each Bug You Find today, and thought I would share it: "The key idea behind...
- Google Chrome: the OS. Google announced last Tuesday that it has its sights on dethroning Microsoft as desktop OS king: "The new operating system, announced late Tuesday night on Google's Web site, will be...
- How to fake a TreeNodeCollection subclass in .NET If you've ever had reason to try to extend the standard Microsoft web TreeView control, you will have no doubt noticed that MS was quite unkind to you and sealed...
- Free Firewall Recommendations (Protect Yourself Online With These Free Firewalls) If your home computer is connected to the internet, or to other computers that are connected to the internet - you need a firewall. It's as simple as that. Hackers...
- How to Delete Empty Folders - FREE! While performing a disk cleanup recently, I had cause to locate and delete any empty folders under a root folder. I knew there had to be a batch file command...
Related Websites - Role Of Meta Title Tag In SEO By: Prashant K Shukla, SEO Consultant Do you want to secure a top ranking in search engine result pages(SERP)? I think every one is going to answer - Yes. And a very common belief is that add lot of most searched keywords in the meta tags of your web pages......
- Starter Set: Lampe Berger Assortment of 3 Scents - Lavender, Tea and Eucalyptus User Reviews Send this to a friend Starter Set: Lampe Berger Assortment of 3 Scents - Lavender, Tea and Eucalyptus Manufacturer: Lampe Berger Customer Rating: List Price: $19.99 Sale Price: View Sale Price Availibility: View Product Availability Buy Now Product Description Lampe Berger began in France in 1898 with......
- Five Common Myths About Search Engine Picture this scene, an adolescent boy walks into a barber shop and says to the barber, “Don’t touch me, I’m only here because my mom forced me.” Search engine optimizers are sometimes put into the position of the barber. They are knowledgeable and willing to work on their client’s site,......
- Seven Myths About Search Engines Demystified Today there is a lot of information available on the web about how to get good search engine rankings, some information is good and some information is bad. Over the few years search engines have been around, some myths have developed. Some of these myths are actually just out dated......
- SEO Marketing For Google Update There is a lot of talk in the town regarding the latest Google update, which has been nick named as Jagger. Jagger is a 3-part Google update that has changed some of the important rules of determining page rank and this has affected the SEO community in its entirety. The......
