使用javascript如何給url進行編碼

admin發表於2017-04-04

本章節介紹一下如何給url進行編碼,程式碼例項如下:

[JavaScript] 純文字檢視 複製程式碼
var url="http://www.softwhy.com/forum.php?mod=viewthread&tid=17308"
console.log(encodeURIComponent(url));

encodeURIComponent()方法的用法可以參閱javascript encodeURIComponent()一章節。


相關文章