Can someone explain to me this code snippet?
<button id="btn6" href="javascript: void(0)" onclick="function1()" type="submit">Get Link</button>
<script>
function function1() {
var Link = 'https://google.com';
var referr = '';
{
window.location = Link+''+referr;
}
}
</script>
I want to find the complete URL(with parameters) that is sent to the browser when clicking the button
As Andy said, there is a lot of issues with your code but once you fix it, use the URL
object that is provided in modern browsers and the searchParams
function :
var url = "https://google.com/test.html?a=1&b=test-param-sample-123"; //for exemple
var url = new URL(url);
var b = url.searchParams.get("b");
console.log(b); //return the b parameter "test-param-sample-123"
I let you check this article for more informations
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.