Reputation: 99
I have a page, named as index.html
and i want to load it as index.html#home
Because i do have few elements with different ID's, and i want to load the #home content by default.
So when we hit index.html
page it will reload to index.html#home
(unless if no hash is specified in the URL)
How its possible? and forgive my english.
Upvotes: 3
Views: 374
Reputation: 146201
You may try this (Check MDN)
if(!window.location.hash) {
location.hash = '#home';
}
Upvotes: 1
Reputation: 3900
Put this in the (NOT head
- see comments) bottom of your html page:
<script type='text/javascript'>
document.getElementById("home").scrollIntoView();
</script>
Upvotes: 1
Reputation: 21170
If what you're trying to do is scroll to a div on pageload, I suggest reading (/applying) this:
jQuery: how to scroll to certain anchor/div on page load?
Upvotes: 0