admin管理员组

文章数量:1356421

I want to make the browser to scroll the div's id

<div id="test">
   lol
</div> 

So I use this code

window.location = "#test";

but my url now is like this

http://locahost/index.html#test

Is it possible to delete "#test" but go to that ?

I want to make the browser to scroll the div's id

<div id="test">
   lol
</div> 

So I use this code

window.location = "#test";

but my url now is like this

http://locahost/index.html#test

Is it possible to delete "#test" but go to that ?

Share Improve this question asked Jul 5, 2013 at 4:49 user1128331user1128331 7274 gold badges10 silver badges20 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 7

Scroll to the element:

document.querySelector('#test').scrollIntoView();

本文标签: htmljavascript windowlocation idStack Overflow