i want to know how to make it when a a button is pressed it will redirect you to a chosen url. something like this:
<button onclick = "link()">Press to go to link!</button>
function link(){
//leads to url
}
i want to know how to make it when a a button is pressed it will redirect you to a chosen url. something like this:
<button onclick = "link()">Press to go to link!</button>
function link(){
//leads to url
}
You can use window.open to open in new tab.
function link(){
window.open('http://www.google.com');
}
<button onclick = "link()">Press to go to link!</button>
or
function link(){
window.location.href = 'http://www.google.com'; //Will take you to Google.
}
<button onclick = "link()">Press to go to link!</button>
You can try something like this:
<button class="btn" onclick="window.location.href = 'https://www.stackoverflow.com';">Click this link</button>
or
<a href="https://www.stackoverflow.com"><button>Click this link</button></a>
This will direct the page to a expected link