Replacing accents and cedillas

Asked

Viewed 774 times

0

I’m having a problem in javascript do a window.open() with a string the problem is that if the string has accents or cedilhas gives error , someone knows a way to replace the accents or cedilhas by the letter without accent or cedilhas?

1 answer

1


You can use the function encodeURI for URL-Find the characters.

var url = 'http://my.url.com/que/tem/ç/cedilha/e/ãé/acentos';
var encoded = encodeURI(url);
window.open(encoded);

Example in Jsfiddle.

  • I tried but it’s not working

  • If encoding the accented characters doesn’t work, what do you want is to remove the accents? For example, "çaéiôü" => "caeiou"? If that’s the case, you can take a look in this matter of Soen.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.