I want to essentially reload the page I'm on without some of the query strings which might be present (thus changing content on the page). I've found that leaving the href tag empty like so href=""
works, but I wonder if this a safe method, ie. does it work in older browsers?
Edit:
In fact scrap that, leaving it blank doesn't work (some great testing by me there). So, I guess my question now is, how can I reload the same page without any query string values? And without knowing the file name and without using Javascript. I guess I'm looking for something like /
or #
.
I think I know a trick. When you use a <form>
tag with empty action
and no (or GET) method
parameter it will use your url but will replace the GET parameters (query string) with the values in your form, so:
On page http://example.com/foo.html?query=string
<form action="">
<input type="submit" value="hello" />
</form>
If you click on the button you will get to:
http://example.com/foo.html
(Firefox 8)http://example.com/foo.html
(Internet Explorer 9)http://example.com/foo.html?
(Chrome 15)http://example.com/foo.html?
(Safari 5)Edit: the trailing question mark is likely a Webkit issue.
There is an interesting post about empty URLs. It refers to RFC 3986, which defines URLs.
Basically, from a spec point of view you should be save, in that href=""
references the current page.
I assume that all browsers adhere to this, but this is just an educated guess. The HTML5 spec also allows empty URLs.
Edit: To meet the updated question, (almost) removing the query string can be done with href="?"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With