2010-06-23 232 views
2

可能重复:
Adding a parameter to the URL with JavaScript将参数添加到URL?

如果我想假设2个和ID值添加到URL。我怎样才能使用JavaScript?

假设我们有URL:http://localhost/demo/,那么如何添加这2个参数。

+0

做像这样: index.html?parameter1 = val1&parameter2 = val2 – 2010-06-23 10:32:04

+4

这是你在追求什么? http://stackoverflow.com/questions/486896/adding-a-parameter-to-the-url-with-javascript – 2010-06-23 10:32:15

+0

是的,我想要像你提到的 – rajesh 2010-06-23 10:36:51

回答

0
"http://localhost/demo/" + "?name=" + escape(name_var) + "&id=" + escape(id_var) 
+0

一样,但我怎么可以添加我的代码,以便它可以工作正确.... – rajesh 2010-06-23 10:39:54

0

如果你想重定向到使用JavaScript的位置,请: location.href="http://localhost/demo/?" + id + "=" + value + "&" + id2 + "=" + value2

如果只是想修改什么在导航栏中你想

location.hash = id + "=" + value;