How can I get the string after the sign #:
// get current url
var url = window.location.href;
// output: //http://www.test.com/Tests/pagination.php?page=4#tab2
alert(url);
How can I get the name tab2 which is after #
Thanks in advance
How can I get the string after the sign #:
// get current url
var url = window.location.href;
// output: //http://www.test.com/Tests/pagination.php?page=4#tab2
alert(url);
How can I get the name tab2 which is after #
Thanks in advance
Use this code:
window.location.hash
Return the anchor part of a URL. Assume that the current URL is http://www.example.com/test.htm#part2: #part2
The Window.location read-only property returns a Location object with information about the current location of the document.
Though Window.location is a read-only Location object, you can also assign a DOMString to it. This means that you can work with location as if it were a string in most cases: location = 'http://www.example.com' is a synonym of location.href = 'http://www.example.com'.
More Read Here