tags:

views:

36

answers:

2

When I refresh a page, browsers retain the scroll position of the page if there is a # in the URL, How to over ride this behavior and scroll to the top of the screen without using JavaScript.

My URL is like http://example.com/#

Update By default the URL is http://example.com/ and the # character is added to the URL upon clicking some part of the page.

+1  A: 

In case you have a <form action="#" ...> somewhere, that's your culprit. Change it to <form action="" ...>.

tdammers
not actually, '#' is from `<a href="#" onclick=.....`
Mithun P
href="#"? Oh dear. http://icant.co.uk/articles/pragmatic-progressive-enhancement/#build
David Dorward
What's in the onclick?
tdammers
A: 

Anyway you have a # symbol either in form action or in link href.

Replace # with javascript:; in links.

Replace # with index.php or leave blank (<form action=""...) in forms.

Otar
Niiigh. http://icant.co.uk/articles/pragmatic-progressive-enhancement/#build !
David Dorward
Er... isn't mine almost the same?
Otar
No, it isn't. When the JS fails, "javascript:;" does not "work".
David Dorward