Javascript Redirect onClick

Posted under » JavaScript on 30 October 2009

If no PHP available, this is an easy feat

Go intro

If you just want the page to redirect to another.

<script type="text/javascript">
window.location = ""

This is highly unlikely scenario.. most of the time we link to an external .js file say MrsLK1.js for example so we put this on top of the body.

<script type="text/javascript" src="MrsLK1.js"></script>

Contents of the MrsLK1.js looks like this.

function pergi()
  window.location = "";

Then on the body we put this button-text which will trigger the js.

<button onclick="pergi()">Click me</button>
You can make this function flexible.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data