Remove hash tag from the current url-Javascript

By
Advertisement


Introduction:
In my previous article I have explained about Move items in drop down list from left to right using jQuery. In this article I am going to explain about how to remove hash tags from the current url using javascript.

Explanation:
To below code is used to remove the hash tags from the current url and to reload the page with the new url(without hash tags).

<script type="text/javascript">
    //gets the current url
    var currenturl = window.location.href;
    //checks whether the url contains hash tag
    var index = currenturl.indexOf('#');
    //indexOf method returns the index of the '#' character
    if (index > -1) {
        currenturl = currenturl.substring(0, index);
    }
    //Loads the same page but without hash tags
    window.location = currenturl;
</script>

Do you like this article? Help us to improve. Please post your comments below.

0 comments:

Post a Comment

Online Casino