0

Here is the html code

<head runat="server">
<title>Untitled Page</title>

<script type="text/javascript">
    function func()
    {
        document.location.href="www.google.com"
    }
</script>

</head>
<body>
    <form id="form1" runat="server">
    <input type="button" runat="server" onclick="func();" />
    </form>
</body>
</html>

The redirect isn't working

2 Answers 2

2

There is no document.location.

Use either window.location.href, or location.href (I prefer the latter :))

Sign up to request clarification or add additional context in comments.

Comments

2

Because it should be window.location.href.

REF: https://developer.mozilla.org/en-US/docs/DOM/window.location

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.