我有这段代码:
if(questionMarker >= 10) //If we've answered 10 questions...
{
alert("You have completed the quiz!"); //The quiz is completed
document.write("Your Answers:"); //Displays their answers
document.write('<br>' + questionTop[0] + " + " + questionBot[0] + " = " + answers[0] + " Correct Answer is: " + correct[0]);
document.write('<br>' + questionTop[1] + " + " + questionBot[1] + " = " + answers[1] + " Correct Answer is: " + correct[1]);
document.write('<br>' + questionTop[2] + " + " + questionBot[2] + " = " + answers[2] + " Correct Answer is: " + correct[2]);
document.write('<br>' + questionTop[3] + " + " + questionBot[3] + " = " + answers[3] + " Correct Answer is: " + correct[3]);
document.write('<br>' + questionTop[4] + " + " + questionBot[4] + " = " + answers[4] + " Correct Answer is: " + correct[4]);
document.write('<br>' + questionTop[5] + " + " + questionBot[5] + " = " + answers[5] + " Correct Answer is: " + correct[5]);
document.write('<br>' + questionTop[6] + " + " + questionBot[6] + " = " + answers[6] + " Correct Answer is: " + correct[6]);
document.write('<br>' + questionTop[7] + " + " + questionBot[7] + " = " + answers[7] + " Correct Answer is: " + correct[7]);
document.write('<br>' + questionTop[8] + " + " + questionBot[8] + " = " + answers[8] + " Correct Answer is: " + correct[8]);
document.write('<br>' + questionTop[9] + " + " + questionBot[9] + " = " + answers[9] + " Correct Answer is: " + correct[9]);
document.write('<br>' + "You got " + correctAnswers + " answers right out of 10."); //Shows how many answers they got right
document.write('<br>' + "You got " + correctAnswers*10 + "% of the questions right."); //Calculates their percent right
document.write('<br>' + '<button id="newQuiz" type="button" onclick="window.location.reload()">New Quiz</button>'); //Creates new button to reload the screen and start again
document.write("</iframe>");
}
如果我直接加载页面,它会正确显示。但作为一个iFrame,我得到的唯一结果是“你的答案:”。这仅适用于IE9,Chrome和FF可以接受。
整页在这里:http://www.innogeek.com/java/index.html iFrame页面位于:http://www.innogeek.com/java/frame.html
如果输入10个答案,则应显示结果。
答案 0 :(得分:0)
我使用IE9时遇到了类似的问题 - 我的测试是使用本地文件,所以它的url启动了FILE://这似乎会导致IE9出现问题。
我将其切换为使用document.body.innerHTML += "Hello IE9";
类型代码,它可以正常工作。如果我有更多的时间,我会使用createElement
等。
当文档使用file:protocol document.write似乎真的废弃了DOM。
您的网站正在使用http:并且document.write代码似乎对我有用,您是否使用文件进行测试:?
来自gogling的建议......不要使用document.write
!