首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >窗口位置未按预期工作

窗口位置未按预期工作
EN

Stack Overflow用户
提问于 2013-02-17 10:20:20
回答 1查看 156关注 0票数 0

我期望下面的JavaScript函数重定向到与我的路由文件匹配的URL。

代码语言:javascript
运行
AI代码解释
复制
function getUrl() 
{   
    var hash= $('#hashText').val();

    // When the user has not entered a hash, alert to inform them.
    if (!hash)
    {
        alert("Please enter a hash first.");
    }
    else
    {
        alert("Redirecting to ... http://localhost:8080/tasks/" + hash);
        window.location = "http://localhost:8080/tasks/" + hash;
    }
}

下面是我的路由文件中相应的路由条目。

代码语言:javascript
运行
AI代码解释
复制
GET     /tasks/:hash                controllers.Application.getTask(hash: Int)

然而,这一职能的结果是:

http://localhost:9000/tasks?hash=2014281623

EN

回答 1

Stack Overflow用户

发布于 2013-02-17 10:37:13

如果您将代码更改为:

代码语言:javascript
运行
AI代码解释
复制
var url = 'http://localhost:9000/tasks/';
url += escape(hash);
window.location = url;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14924411

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文