UncleCoder.com

UncleCoder.com

Free programming examples and instructions

Redirect URL - Javascript

Demo and code for how to redirect URL in javascript.

by Athil


Posted on 27 Jun 2018 Category: Javascript Views: 56

Edited on 29 Jun 2019


Here I am going to show how to redirect URL in javascript.

DEMO

 window.location='http://www.google.com';

This code will go the website google.com.

Demo Code

HTML

 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Demo for Javascript redirect</title>
</head>
<body>
<h1>Demo for Javascript redirect </h1>

    <button onclick ="redirect();" >  Redirect to google  </button>

  
</body>
</html>

Javascript code

 function redirect()
 {
      window.location='http://www.google.com';
 }

 



Leave a Comment:


Advertisement