I believe this will work:
<body>
<a id="link-to-edit" href=""> Click here to execute </a>
</body>
<script>
baseurl="https://abc.azurewebsites.net?="
link = document.getElementById("link-to-edit")
link.href = baseurl + window.location
</script>
This will use javascript to programmatically update the href to the baseurl plus current location as soon as the page/script loads. Then when you click the link will be executed properly. The key is that the href must be set at the time of clicking. In your examples, you set the href AFTER the user clicks and thus the link will not work as you intend. Hope that helps!
I want to create a custom hyperlink which passes current URL as one of the parameter to web app endpoint (abc.azurewebsites.net).
These are the versions I tried with thought process of getting the element by Id and update the href using basic HTML properties but no luck.
Approach 1
> <script> baseurl="abc.azurewebsites.net?="
function buildURL(item) {
> item.href=baseurl+window.location.href;
> return true; }
</script>
> </head> <body> <a onclick="return buildURL(this)" href="">Google</a> </body>
Approach 2
Click on this <a href=""
target="_self" id= "test" onclick = buildURL() >Link </a> to execute
<script>
var el_up = document.getElementById("test");
function buildURL() {
this.href = "abc.azurewebsites.net?=" + document.URL;
}
</script>
Any suggestions please. Is it even possible?
Update: Just to mention, I’m trying this from Azure Devops description section

Thanks for the reply but with this the link itself is not clickable and I guess that’s the core problem here. Code assumes that href value will be defined at runtime (function in the script) but that never happened. Why I think so? Because even If I provide a blank href in the anchor tag ( Click here to execute ), link is clickable and pointing to current URL.
HI, I edited my response to include the empty href and also added the protocol “https://” to the baseurl, as this may be required for proper link functioning. I tested this in jsbin and it is working, can you describe exactly what you mean by the “link is not clickable” ?
What I meant by link not clickable is, hyperlink was not becoming active when href = “” wasn’t used. Though, even after this the link still points to current URL (guess that’s how markdown works). The logic written in