2016-03-08 37 views
-1

我想參數傳遞到像這樣的URL:的JavaScript如何編碼的網址,其中有 ' - '

bike-my-myRecharge-dailyAccount-detail.html?billTime=2016-02 

,但我得到的網址永遠是:

bike-my-myRecharge-dailyAccount-detail.html?billTime=2013 

我已經試過encodeURIComponent()encodeURI(),但它不起作用。

+1

進行編碼,以%2D

您可以直接測試編碼的URL請發表您使用的參數添加到URL中的代碼。 – sideroxylon

+0

'2016' ....'2013'?怎麼樣 ? – Rayon

+0

在url中有'-'完全有效。你有沒有ani問題:http://7-zip.org/? – DDan

回答

0

我試過encodeURIComponent()和encodeURI(),但它不起作用。

您可以發佈您看到的錯誤。

//test url 
var uri = "my test.com?bike-my-myRecharge-dailyAccount-detail.html?billTime=2016-02"; 

var res = encodeURI(uri); 

-將在W3C