Use onclick location href to call website or page in HTML. It can use mostly tags available in HTML.
JavaScript onclick href Example
HTML example code:
Linking pages using buttons click event
<html>
<body>
<input type=button onClick="location.href='index.html'"
value='click here'>
</body>
</html>
In tag <a>
<html>
<body>
<a onclick="location.href='abc.htm'">Visit Page</a>
</body>
</html>
In Function
<html>
<body>
<a onclick="go()">Visit Page</a>
<script type="text/javascript">
function go(){
var a1 = document.getElementsByTagName("a")[0];
a1.href = "abc.htm";
}
</script>
</body>
</html>
Output:
Do comment if you have any doubts and suggestions on this JS href tutorial.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version