Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferent encoding issue
    primarykey
    data
    text
    <p>I'm writing an android app that implements a web server that sends pages containing text messages. By client side I developed a web interface. This interface contains some DIVs that are filled using ajax and in particular with this functions that gets a page and put it into a specified div:</p> <pre><code>function getElementFromId(myElement) { var elem; if(document.getElementById) elem = document.getElementById(myElement); else elem = document.all[myElement]; return elem; } function getXMLHttpRequest() { var XHR = null, browser = navigator.userAgent.toUpperCase(); if(typeof(XMLHttpRequest) == "function" || typeof(XMLHttpRequest) == "object") XHR = new XMLHttpRequest(); else if(window.ActiveXObject &amp;&amp; browser.indexOf("MSIE 4") &lt; 0) { if(browser.indexOf("MSIE 5") &lt; 0) XHR = new ActiveXObject("Msxml2.XMLHTTP"); else XHR = new ActiveXObject("Microsoft.XMLHTTP"); } return XHR; } function pageInDiv(nomeFile,divId) { var ajax = getXMLHttpRequest(), elem = getElementFromId(divId), usaLink = true; if(ajax) { usaLink = false; ajax.open("get", nomeFile, true); //ajax.setRequestHeader("connection", "close"); ajax.onreadystatechange = function() { if(ajax.readyState == 4) { if(ajax.status == 200) elem.innerHTML = ajax.responseText; else elem.innerHTML += "Error: " + statusText[ajax.status]; } } ajax.send(null); } return usaLink; } </code></pre> <p>Now there's the problem! When I call <code>pageInDiv("pageWithText.html",myDiv)</code> the div is filled correctly, except for accented caracters. If the text contains àèìòù, the div will contain strange symbols, but (this is the strangest thing) if I open the page <code>http://.../pageWithText.html</code> directly in the browser it appears perfectly!</p> <p>What's the problem? Thank you in advice</p> <p><strong>Update</strong></p> <p>This a piece of the web interface code:</p> <p><code>&lt;body onLoad=" pageInDiv('conversations.html', 'conversations');&gt;</code></p> <p>And this is the code of conversations.html:</p> <pre><code>&lt;div id="conversations" class="list"&gt; &lt;div id="main"&gt; &lt;div id="msgTitle"&gt;Io&lt;/div&gt; &lt;div id="message"&gt;&lt;div id="img"&gt; &lt;img class="convimg" src="contactphoto_8259.jpg"&gt;&lt;/div&gt; &lt;div id="text"&gt;������&lt;/div&gt;&lt;/div&gt;&lt;div id="line"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload