基本編碼的URL通常包含「?」和幾個「&」。該網址是否可以進行雙重編碼以消除所有「?」和所有的「&」。它會起作用嗎?這樣做是對的嗎?URL可以被雙重編碼嗎?
請檢查樣本編碼網址 -
http://www.permadi.com/tutorial/urlEncoding/example.html?var=This+is+a+simple+%26+short+test&testmail=the+master.
基本編碼的URL通常包含「?」和幾個「&」。該網址是否可以進行雙重編碼以消除所有「?」和所有的「&」。它會起作用嗎?這樣做是對的嗎?URL可以被雙重編碼嗎?
請檢查樣本編碼網址 -
http://www.permadi.com/tutorial/urlEncoding/example.html?var=This+is+a+simple+%26+short+test&testmail=the+master.
使用encodeURIComponent
,就會產生:
的http%3A%2F%2Fwww.permadi.com%2Ftutorial%2FurlEncoding%2Fexample.html %3Fvar%3DThis%圖20是%20A%20simple%20%26%20short%20test%26testmail%3Dthe%20master%20
它應該在所有的主流瀏覽器。
謝謝,它根據需要進行編碼。但嘗試使用encodeURIComponent(完整的stackover url)編碼後訪問一些stackoverflow網址。無法訪問! –
請參閱[this](http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent)線程。 – alesc