iJade
iJade

Reputation: 23811

url redirect not working in javascript

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

Upvotes: 0

Views: 3867

Answers (2)

Mathew Thompson
Mathew Thompson

Reputation: 56449

There is no document.location.

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

Upvotes: 2

VisioN
VisioN

Reputation: 145458

Because it should be window.location.href.

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

Upvotes: 2

Related Questions