5

クエリ文字列パラメーターを取得して、これを実行しようとしています:

var hello = unescape(helloQueryString); 

そしてそれは戻ります:

this+is+the+string

それ以外の:

this is the string

%20 がそこにある場合はうまく機能しますが、それは + です。+記号がスペースに移動するようにこれらを適切にデコードする方法はありますか?

ありがとう。

4

2 に答える 2

7

decodeURIComponent関数はデコードを正しく処理します。

decodeURIComponent("this%20is%20the%20string"); // "this is the string"

次の記事をご覧ください。

于 2010-05-27T04:16:39.420 に答える
1

後にこの行を追加するとうまくいきます:

hello = hello.replace( '+', ' ' );
于 2010-05-27T03:48:43.707 に答える