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 - 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...
- 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...
- How to find what's running under SVCHost.exe My PC was behaving sluggishly the other day. I tried to be patient, but had to fire up the task manager when I could bear it no longer. That's when...
- 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...
Related Websites - Search Engine Friendly Content Management Systems What is a Content Management System? A Content Management System (CMS) is a third party software application which allows web site administrators to add, update or delete content, photos, and documents to their web site in “real time”. Many web sites are modified using these web-based tools as they require......
- SEO and Web Design When we talk about the relationship between SEO and web design, it's usually the technical part of the website design art that's relevant, not the visual part (though certain aspects of visual design have their impact on SEO/SEM, as will be shown below). One of the latest trends in the......
- 5 Super Powered Strategies To Increase Your Web Traffic Using Social Networks The www is awash with web marketers using Social Bookmark sites, like Propeller and Digg, to drive large amounts of traffic to their business sites, increasing sales and profits. This is not a replacement phenomenon. After all, from the dawn of social networking sites there are a plentiful herd of......
- 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......
- 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......
