【发布时间】:2010-10-25 05:17:53
【问题描述】:
我有一些这样的代码,
<form id="abc">
<input type="text" id="txt" />
</form>
现在我想像这样重定向,
var temp = $("#txt").val();
url = "http://example.com/" + temp;
window.location.replace(url);
// or window.location(url);
jQuery 中是否有解决此问题的方法?它仍然让我拥有url = http://example.com。
【问题讨论】:
-
非常感谢大家!现在我还是不知道window.location和window.location.replace有什么区别。在我的示例中,我只需要像这样将 url 发布到我的页面:abc.com/abc 让 abc 在我的数据库中搜索 abc 是用户输入的内容,然后按 enter 或按钮,但他们总是返回 abc.com?name=abc 所以我认为我可以在提交事件中触发以重定向并将我的网址更改为我想要的,但他们仍然什么都不做。就是这样,顺便再次感谢您!
-
我在这里解释了window.location和window.location.replace之间的区别:stackoverflow.com/questions/846954/…
标签: javascript jquery url redirect