Posts tagged: CSS

Jun 18 2009

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. :)

Blog Traffic Exchange Related Posts Blog Traffic Exchange 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......