HTML: Navigate to a different url using button [closed]

I need to create a link or a button so that users can navigate to different urls (needs to be generated in a js function based on values selected in multiple dropdown)

I tried with a button but it doesn’t navigate to the link, and with not able to change values of href it adds to previous values.

Can you please help

Answer

function link(url){
    window.location.assign(url);
}
<button onclick="link('http://www.stackoverflow.com/')">Go to Stack Overflow without using an &lt;a&gt;!</button>

Leave a Reply

Your email address will not be published. Required fields are marked *