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 - Are Free Antivirus and Firewall Products Really Any Good? There was a time in my life when I used security and protection suites like Norton and McAfee, but after a while I grew unsatisfied with them. "But Norton and...
- 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...
- Microsoft FxCop doesn't like Microsoft generated code! The other day I thought it might be nice to "do the right thing" and give my code a run against Microsoft's FxCop. I ran it right out of the...
- 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...
- 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...
Related Websites - 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,......
- 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......
- 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......
- Ocean Breeze Scent Lampe Berger Lamp Perfume 500 ml 17 fl oz User Reviews Send this to a friend Ocean Breeze Scent Lampe Berger Lamp Perfume 500 ml 17 fl oz Manufacturer: Lampe Berger Customer Rating: List Price: $21.99 Sale Price: $17.00 Availibility: View Product Availability Buy Now Product Description Lampe Berger began in France in 1898 with a pharmacist, Maurice......
- 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......
