0

This is my url:

http://example.com/index.php#motto

On page load remove #motto with Javascript.

2
  • you need to alter the window.location property in this case. Commented Nov 7, 2014 at 16:36
  • 1
    Have you tried anything? Commented Nov 7, 2014 at 16:38

2 Answers 2

1

try this: window.location.hash=""

Sign up to request clarification or add additional context in comments.

3 Comments

Whit that the url became this: example.com/index.php#. Can i remove the #?
i would suggest you to check history.pushState function
will be something like this: history.pushState("", document.title, window.location.pathname); but it is not cross browser, in ie8 or ie9 i don't think it will work
-1
$.fn.urlHash = function()
{
  return window.location.hash.replace('#','');
};
$.urlHash();

3 Comments

Please a some comments about the code you are providing.
Why assign a stateless function to the jQuery (or similar) global object?
The post was edited. He was asking about jquery.I was just trying to answer like him asked. Ok teacher!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.