Posts tagged: Javascript

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
  • Three Basic Steps To Search Engine Optimization Search engine optimization is the art and science of making web pages appear attractive to the search engines. The better optimized a website is, the higher the ranking it will receive from a search engines web crawlers, the higher its ranking the more traffic your website will have, the......
  • 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......
  • 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......
  • 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......
  • Search Engine Optimization Seo Search Engine Optimization (SEO) in Dubai Like other business homes Dubai conjointly have internet solutions firms that provide complete range solutions of internet development are operating on new trends and selling ways for on-line businesses. Dubai is the business hub for the globe trade. It’s the time of on-line businesses.......