Replace accents and keys

0

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

    
asked by anonymous 16.05.2016 / 18:27

1 answer

1

You can use the encodeURI function to URL-encode the characters.

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

Example in JSFiddle .

    
16.05.2016 / 18:33