MattsBits
MattsBits

MattsBits

Use Javascript To Create A Button Link  

by Matt Hawkins, 07/02/2011
Categories : JavaScript

You can use Javascript to create a button that when pressed will provide a link to a specific URL.

Copy the following Javascript function into the Head of your HTML page :

<SCRIPT LANGUAGE="JavaScript">
<!-- Author : Matt Hawkins -->
<!-- Site   : http://www.mattsbits.co.uk/ -->
<!-- Begin
function GoToURL(sURL) { window.location = sURL; }
//  End -->
</script>


Then you can create a button link using this HTML :

<form>
<input type=button value="Button Link" onClick="GoToURL('http://www.example.com/');">
</form>


When the user clicks the button the GoToURL function is called. The page URL to link to is passed as a parameter and the javascript redirects the user to this page.

Author : Matt Hawkins  Last Edit By : Matt Hawkins
PHP Powered  MySQL Powered  Valid XHTML 1.0  Valid CSS  Firefox - Take Back The Web  EUKHost - Recommended Webhosting Solutions

MattHawkins CMS v3.0 - Copyright 2009-2017