28 Aralık 2008 Pazar

javascript / escape(), encodeURI(), encodeURIComponent()

xkr.us / javascript / escape(), encodeURI(), encodeURIComponent()

My note: Use encodeURIComponent() if is supported. Otherwise use escape instead of "not doing anything".

I recommend that you add such a utility function in your utility .js file:
function urlEncode(string) {
  if (window.encodeURIComponent) {
    return encodeURIComponent(string);
  }
  // if encodeURIComponent is not supported, use escape
  return escape(string);
}

Hiç yorum yok: