javascript - url 重定向在 JavaScript 中不起作用

标签 javascript html

这是html代码

<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>

重定向不起作用

最佳答案

没有document.location

使用window.location.hreflocation.href(我更喜欢后者:))

关于javascript - url 重定向在 JavaScript 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15131645/

相关文章:

.net - 如何创建屏幕抓取? "i want to know just the cycle"

angularjs - 无法清除表格

javascript - 类型错误 : Cannot read property 'value' of undefined on components (ReactJS forms)

javascript - 使用jquery隐藏按钮

javascript - 使用 Passport js 和 mongoDB 用户登录

html - 如何使用 htaccess 将 website.com/和 website.com/index.php 重定向到另一个页面

html - 使用 onclick 函数更改背景颜色

javascript - 将数学公式存储在变量中

javascript - 使用 WebGL 将三 Angular 形变成科赫雪花

javascript - Vimeo 视频(或 Youtube)的动态调整大小