For A Url in jquery:
You Could Try The prop Method:
$(location).prop('href')
Or Try The attr Method:
$(location).attr('href')
Snippet:
function oneurl(){
alert($(location).prop('href'))
}
function twourl(){
alert($(location).attr('href'))
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<button onclick="oneurl()">#1</button>
<button onclick="twourl()">#2</button>