开发者

div scroll to in javascript

开发者 https://www.devze.com 2022-12-13 02:31 出处:网络
I have several divs with content. Some of the context is 开发者_StackOverflow社区wrapped with, content <a name=\'SomeName\'> cool content </a> more content

I have several divs with content. Some of the context is 开发者_StackOverflow社区wrapped with,

content <a name='SomeName'> cool content </a> more content

In Javascript how do I force the SomeName name to scroll into view for that DIV only. The catch is that there are many DIVs on the page with content.

I have the Div's object known. The Div can contain other divs etc in a hierarchy. Somewhere in there is the SomeName anchor.

site: http://BiblePro.BibleOcean.com


what about scrollintoview command? Not sure if thats IE specific.

document.getElementById("SomeName").scrollIntoView(true);


You could set the Window Location to include the # anchor, and the browser will scroll to it.

Window.Location = "http://yourSite.com/YourPage.html#SomeName";
0

精彩评论

暂无评论...
验证码 换一张
取 消