I need that use href=""
attribute for button
like this <button href="link">click me</button>
Instead of <a href="link">
that's wrong .
I think that I've to try this code
<button onClick="FN('MY Link For Example www.stackoverflow')" >click me</button>
<script>
function FN('URL'){
--> Go to MY Link For Example www.stackoverflow
}
<script>
So what do u guys suggest I should do ?
I need that use href=""
attribute for button
like this <button href="link">click me</button>
Instead of <a href="link">
that's wrong .
I think that I've to try this code
<button onClick="FN('MY Link For Example www.stackoverflow.')" >click me</button>
<script>
function FN('URL'){
--> Go to MY Link For Example www.stackoverflow.
}
<script>
So what do u guys suggest I should do ?
Share Improve this question edited Jan 21, 2020 at 20:43 isherwood 61.2k16 gold badges122 silver badges170 bronze badges asked May 28, 2015 at 7:38 Danin NaDanin Na 4091 gold badge3 silver badges13 bronze badges 04 Answers
Reset to default 4Try this. This will navigate to the link on click.
<button onclick="window.location.href='http://www.stackoverflow.'">click me</button>
Why you don't use <a type="button" href=""></a>
Or if you really want a button, so <button onclick="window.location.href=""></button>
I think this will solve your problem
<a href="http://www.stackoverflow./">
<button>click me</button>
</a>
href attribute can not be used on button tag , if you want button like appearance for your a tag you can use add style to your a tag and make it look like button , add bootstrap reference then add button class to your anchor tag. Custom Bootstrap Button , but if you still want to use button tag then adding onclick event is better option