Paste this code in html body:
<a href=”#detail” onclick=”CallUrl();”>Click to get url</a>

Now start scripting

1. Add jquery library file
<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js”></script>

2. paste the following code in script tag as below:

<script>
// function definition
function CallUrl(){
var pageURL = $(location).attr(“href”);
alert(pageURL);
}
</script>