encoding - Unknown symbols displayed in czech words in javascript application -
i have unknown symbols displayed in javascript application try catch construction using czech language when use coding windows-1250. these symbols displayed question marks in diamond.
html
<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"/> <title>konstrukce try/catch</title> <script type="text/javascript" src="number.js"></script> </head> <body> <form name="formular" id="formular" action="#"> <div id="cislodiv">zadejte číslo v rozsahu 1 až 100: <input id="cislo" name="cislo"> <span id="informace"> </span></div> <div><input id="odeslatformular" type="submit"></div> </form> <script type="text/javascript"> function inicializuj() { document.forms[0].onsubmit = function() { return zkontrolujformular(this) }; } window.onload = inicializuj; </script> </body> </html>
javascript
function zkontrolujformular() { try { var cislo = document.forms[0]["cislo"]; if (isnan(cislo.value)) { var chyba = new array("nejedná se o číslo",cislo); throw chyba; } else if (cislo.value > 100) { var chyba = new array("zadané číslo je větší jak 100",cislo); throw chyba; } else if (cislo.value < 1) { var chyba = new array("zadané číslo je menší jak 1",cislo); throw chyba; } return true; } catch(objektvyjimky) { var informace = document.getelementbyid("informace"); var textchyby = document.createtextnode(objektvyjimky[0]); var novyspan = document.createelement("span"); novyspan.appendchild(textchyby); novyspan.style.color = "#ff0000"; novyspan.style.fontweight = "bold"; novyspan.setattribute("id","informace"); var rodic = informace.parentnode; rodic.replacechild(novyspan,informace); objektvyjimky[1].style.background = "#ff0000"; return false; } }
have tried using utf-8 encoding?
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
or shorter:
<meta charset="utf-8" />
nowadays using encoding other utf-8 rather rare. may need in special circumstances, whenever can try use utf.
Comments
Post a Comment