我想解碼一個字符串,而不是URL。我試過了逃生功能,它工作正常。但逃生功能現在已經過時在Javascript中解碼一個字符串不是url
var a = "mysap'fff'"; //it could be any string
var usingEscape = escape(a);
alert(usingEscape);
的結果是:的mySAP%27fff%27這是很好的
var usingEncodeUri = encodeURI(a);
alert(usingEncodeUri);
結果是:mysap'fff
var usingEncodingUriComponemt = encodeURIComponent(a);
alert(usingEncodingUriComponemt);
結果是:mysap'fff
現在我需要通過轉義函數給出的結果。任何候補相同
感謝
http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery試試這個 –
轉義仍然適用於我 –
爲什麼你需要轉義單引號?這些在URL中都很好。 – Thilo