JavaScript Program for Page Redirection Using location Object

Write a JavaScript program for page redirection using location object.



Source Code
<html>

<head>
    <script type="text/javascript">
        function redirect(val) {
            if(val == 1)
                location.href="http://www.google.com";
            if(val == 2)
            location.href="http://drive.google.com";
        }
    </script>
</head>

<body>
    <p>Click on button where you want to Redirect..</p>
    <input type="button" value="Google" onclick="redirect(1)" />
    <input type="button" value="Google Drive" onclick="redirect(2)" />
</body>

</html>
Output