I'm using javascript in blogger but i'm having a strange behavior using the chars '¡' and '?'.
For example, the following code will show ñéúüëò¡!¿? inside the div but ñéúüëò¡!¿? as alert message.
<div id="test">
</div>
<script>
(function () {
document.getElementById("test").innerHTML = 'ñéúüëò¡!¿?';
alert('ñéúüëò¡!¿?');
})();
</script>
</pre>
If we look at the generated code, we can see that the javascript tag has been converted to:
<script>
(function () {
document.getElementById("test").innerHTML = 'ñéúüëò¡!¿?';
alert('ñéúüëò¡!¿?');
})();
</script>
However, I can use an external js
<div id="test">
</div>
<script src="http://foo.bar/file.js"></script>
Being the js file (utf8 encoded):
document.getElementById("test").innerHTML = 'ñéúüëò¡!¿?';
alert('ñéúüëò¡!¿?');
An the result is the expected one: ñéúüëò¡!¿? inside the div and ñéúüëò¡!¿? as alert message.
Still more weird, I can write the following code in blogger, which leads to the wanted behavior, even if it's not too clean:
<div id="div1" style="display:none">¡</div>
<div id="div2" style="display:none">¿</div>
<div id="test">
</div>
<script>
(function () {
document.getElementById("test").innerHTML = 'ñéúüëò¡!¿?';
alert('ñéúüëò'+ document.getElementById('div1').innerHTML + '!' + document.getElementById('div2').innerHTML +'?');
})();
</script>
Can someone explains me how could I write proper and clean code to solve this without using external js files?