2014-03-05 29 views
0

想,我我當前網址:重定向到一些另外在網址URL中

http://localhost:3000/contests 

在按下按鈕後,我要重定向到以下網址:

http://localhost:3000/contests?keywords=algo 

我的問題是,我想重定向到的路徑與像其他附加信息:

http://localhost:3000/contests?keywords=algo&show=present 

這裏,& show = present被添加到重定向的url。我怎麼能使用JavaScript?

我怎樣才能得到使用javascript的重定向url?

+0

顯示一些代碼,使人們可以瞭解你所要完成 – Daniel

回答

-1
location.href = location.href + "?keywords=algo" 

也請與window.location對象at MDN

+0

我需要重定向URL什麼更好的畫面,location.href只給出了當前的URL。 – Emu

1

在你點擊按鈕做這一切的其他可能性。

var url=document.URL + "&show=present"; 
    window.location.href = url; 

使用document.URL獲取當前網址。

希望這會幫助你!

相關問題