Цитата:
|
Цитата:
А чем его можно заменить в таком случае? И вообще почему он на него ругаетса? |
со стилями проблему решыл просто явно ему задавал вот так
var div = document.getElementById('id') //var decoration = xml.querySelector('style'); div.style.border = $(xml).find('style').attr('border'); div.style.width = $(xml).find('style').attr('width'); div.style.height = $(xml).find('style').attr('hight'); div.style.padding = $(xml).find('style').attr('padding'); div.style.margin = $(xml).find('style').attr('margin'); div.style.position = $(xml).find('style').attr('position'); Теперь рамку рисует отлично.Все работает почти коректо осталось исправить какието мелочи. Вообще я в шоке,насколько IE "тупой". Чтобы IE работал корректно ему всегда нужно все задавать явно?.Тоесть вот так он нехотел работать output.value=error ? ''+ResultTextFalse+'' : ''+ResultTextTrue+''; а так работает коректно var c=document.getElementById('output'); c.value=error ? ''+ResultTextFalse+'' : ''+ResultTextTrue+''; И да у меня ище такой вопрос,почему стоит <meta charset="utf8" /> а вот здесь var b=document.getElementById('output'); b.value='Пройдите тест ище раз' выводит иероглифы? Он же вроде должен читать все символы по русски,или нет?ну вернее в хроме мозиле сафари и т.п. браузерах все норм а IE ругаетса,может ище что-то помимо <meta charset="utf8" />нужно написать ? Ну а вообще спасибо за помощь огромное |
utf-8 вроде должно быть, а не utf8. К тому же сервер может выставить другую кодировку в заголовке Content-Type, ей отдается предпочтение.
|
danik.js,
Спасибо вам за некие пояснение=) Если вдруг у кого будут похожые проблемы то решил их так <html> <head> <meta charset="utf-8" /> <title>Test</title> <script type="text/javascript" src="jquery.js"></script> <script src="script.js" type="text/javascript"></script> <script type="text/javascript"> var answer={} $(document).ready(function(){ $.ajax({ type: "GET", url: "test.xml", dataType: "xml", success: vasa }); var button2 = document.getElementById("id1"); button2.style.display='none'; var button3 = document.getElementById("id3"); button3.style.display='none'; function vasa(xml) { attemptsanswer=$(xml).find('attemptsanswer').text(); attemptext=$(xml).find('attemptext').text(); attemptext1=$(xml).find('attemptext1').text(); textanswer=$(xml).find('textanswer ').text(); $('.cont2').append(''+textanswer+''); textanswer1=$(xml).find('textanswer1').text(); $('.cont2').append(''+textanswer1+''); question=$(xml).find('question').text(); $('.cont1').append('<p><label><h4>'+question+'</h4></label></p>'); question1=$(xml).find('question1').text(); $('.bond1').append('<p><label><h4>'+question1+'</h4></label></p>'); TextButton=$(xml).find('TextButton').text(); $('.onki').append('<p><label><h4>'+TextButton+'</h4></label></p>'); TextButton1=$(xml).find('TextButton1').text(); $('.lolki').append('<p><label><h4>'+TextButton1+'</h4></label></p>'); TextButton2=$(xml).find('TextButton2').text(); $('.lolki1').append('<p><label><h4>'+TextButton2+'</h4></label></p>'); TextButton3=$(xml).find('TextButton3').text(); $('.lolki2').append('<p><label><h4>'+TextButton3+'</h4></label></p>'); ResultTextTrue=$(xml).find('ResultTextTrue').text(); ResultTextFalse=$(xml).find('ResultTextFalse').text(); answer1=$(xml).find('answer').text(); var answers = $(xml).find('answer'); answers.each(function(index){ var a = this.textContent; var rating = +this.getAttribute('rating'); var inputs = document.getElementsByTagName('input'); if(inputs.length<2) { $('.cont').append('<input name="group1" type="radio">'); } else { $('.bond').append('<input name="group2" type="radio">'); } answer[index] = rating; }); var div = document.getElementById('id') //var decoration = xml.querySelector('style'); div.style.border = $(xml).find('style').attr('border'); div.style.width = $(xml).find('style').attr('width'); div.style.height = $(xml).find('style').attr('hight'); div.style.padding = $(xml).find('style').attr('padding'); div.style.margin = $(xml).find('style').attr('margin'); div.style.position = $(xml).find('style').attr('position'); // var p = document.getElementById('id1') // var decoration = xml.querySelector('buttonstyle'); // p.style.position = decoration.getAttribute('position'); // p.style.width = decoration.getAttribute('width'); // p.style.height = decoration.getAttribute('hight'); // p.style.margin-left = decoration.getAttribute('marginleft'); // p.style.margin = decoration.getAttribute('margin'); } }); var pressed=0; var pressed1=0; function TrueAnswer(){ var inputs1 = document.getElementsByTagName('input'); for(var k = 0; k < inputs1.length ; k++){ if(answer[k] == 1){ error=true; break; } } var n=document.getElementById('output'); n.value='бла бла бла'; } function checkAnswer() { var error = false; var inputs = document.getElementsByTagName('input'); for(var i = 0; i < inputs.length ; i++){ var checked = inputs[i].checked; var right = answer[i] == 1; if (checked !== right){ error=true; break; } } if(pressed<attemptsanswer) { i = ++pressed; } else { pressed=0; var button = document.getElementById("button"); button.style.display='none'; var button1 = document.getElementById("id2"); button1.style.display='none'; var button2 = document.getElementById("id1"); button2.style.display=''; button2.onclick = function(event){ button.style.display=''; button1.style.display=''; button2.style.display='none'; g=++pressed1; if(pressed1>attemptsanswer) { button.style.display='none'; button1.style.display='none'; button2.style.display='none'; var button3 = document.getElementById("id3"); button3.style.display=''; alert('ваши попытки закончились.Узнайте правильный ответ'); } } } var c=document.getElementById('output'); c.value=error ? ''+ResultTextFalse+'' : ''+ResultTextTrue+''; return false; } </script> </head> <body> <form onsubmit="return checkAnswer()"> <div id="id"> <div class='cont2' style="margin-left:156px"></div> <hr> <div class='cont1' ></div> <div align="center" class='cont' ></div> <hr> <div class="bond1"></div> <div align="center" class='bond'></div> <hr> </div> <p style="position:relative"><button id="button" type="submit" ><div class='onki'></div></button> <button id="id2" type="reset"><div class='lolki'></div></button><button id="id1" type="reset"><div class='lolki1'></div></button><button id="id3" type="button" onclick="TrueAnswer()" ><div class='lolki2'></div></button></p> <p style=" position:relative"><textarea id="output" readonly></textarea></p> </form> </body> </html> |
Цитата:
|
дабы выводился текст из xml файла(подругому неполучилось выводить)
|
То есть так не работает?
c.value= error ? ResultTextFalse : ResultTextTrue; |
Часовой пояс GMT +3, время: 15:42. |