To use a JavaScript button as a link properly you need to start off with an HTML button element. This is commonly referred to as the button tag in HTML. Below is the code example for a button element.
<button></button>If you put the button tag element in a webpage it will look like this.
Button Tag Element You will notice that it does not have any text associated with it. Put text in the button between the center carrots.
<button>Button</button>This will give you a button that looks like this.
Button Add Text Now add a link element to the button like this.
<button onclick="window.location='http://www.website.com';">Button Link</button>
Another Method Using A HTML Button Tag As A Link
You can use an onClick method with script tags to accomplish this task. See the codes below for JavaScript and jQuery.OnClick Method With Script Tags
Use In Javascript<!--script>
function mylink(){
window.location='http://www.website.com';
}
</script !-->
<button onClick="mylink();">Button Link</button>
Use in jQuery
<button id="webLink">Visit Page Now</button>
<!--script>
$('#webLink').click(function() {
window.location='http://www.website.com';
}); </script !-->
Use in Older jQuery
<button id="webLink">Visit Page Now</button>
$jquery('#webLink').click(function() {
window.location='http://www.website.com';
});