Reputation: 482
I would like to know if there is any possible way to re-write a URL to include a hash tag when the site load?
Example:
www.google.com would automatically become www.google.com#something?
Thank you.
Upvotes: 2
Views: 2908
Reputation: 198
This is an easy way to do it, correct me if i have mis-understood your question ! First use location.hash to add the "#something" to your URL Then redirect to the location using window.location in javascript. Try this snippet:
<html>
<head>
<script type="text/javascript">
location.hash = "something";
window.location = location.hash;
</script>
</head>
</html>
Upvotes: 0
Reputation: 2978
Yes you can do this.
location.hash = 'something';
Running this piece of code will add '#something' to the URL of said page.
Upvotes: 4
Reputation: 20980
If you want to AUTOMATICALLY redirect from www.google.com
to www.google.com#something
you can use firefox's redirector addon.
Whenever you load www.google.com, the addon will automatically change the URL in the location bar to www.google.com#something (or whatever you specify.)
Alternately, you could use firefox addon, called greasemonkey, to write the 1 line script given by Jacob. That will also serve the purpose.
Off course, both these solutions are specific to firefox.
Upvotes: 0