0

When I try to change a paragraph using the innerHTML, it changes some characters. Look at the code:

texto.innerHTML = "Durante as últimas 2 semanas, com que freqüência você foi incomodado/a por qualquer um dos problemas abaixo?";

The output is this: Durante as �ltimas 2 semanas, com que freq��ncia voc� foi incomodado/a por qualquer um dos problemas abaixo?

insted of this: Durante as últimas 2 semanas, com que freqüência você foi incomodado/a por qualquer um dos problemas abaixo? novo

What are those question marks?

2
  • What encoding type have you specified for your HTML? Commented Jan 2, 2014 at 13:08
  • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> Commented Jan 2, 2014 at 18:11

2 Answers 2

1

This is due to an encoding issue. Rather than using accented characters, you need to use the HTML special characters.

For example:

ü should be

&#252;

See a full list here

http://www.w3schools.com/tags/ref_entities.asp

Sign up to request clarification or add additional context in comments.

Comments

0

Looks like you have a different encoding in js files and browser output. Try to change the javascript file encoding to the UTF8 without the BOM.

3 Comments

Yes. I think it could be this. But, how can I change the javascript file to the UTF8 without the Bom?
thanks. I've created a new javascript document, past the old code into it and it worked well. But I still want to know how to change the enconding to UTF8.
Depend on used IDE/Text editor. In IDE try to check the new document settings. For Notepad++ (text editor) you can use special menu "Encoding->Conver to UTF8 without BOM".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.