Javascript IE9中iFrame中的document.write没有输出
我有以下代码:Javascript IE9中iFrame中的document.write没有输出,javascript,internet-explorer-9,syntax-error,Javascript,Internet Explorer 9,Syntax Error,我有以下代码: 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>'
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>");
}
if(questionMarker>=10)//如果我们已经回答了10个问题。。。
{
警报(“您已完成测验!”;//测验已完成
document.write(“您的答案:”;//显示他们的答案
写(“
”+questionTop[0]+“+”+questionBot[0]+“=”+answers[0]+”正确答案是:“+Correct[0]);
写(“
”+questionTop[1]+“+”+questionBot[1]+“=”+answers[1]+”正确答案是:“+Correct[1]);
写(“
”+questionTop[2]+“+”+questionBot[2]+“=”+answers[2]+”正确答案是:“+Correct[2]);
写(“
”+questionTop[3]+“+”+questionBot[3]+“=”+answers[3]+”正确答案是:“+Correct[3]);
写(“
”+questionTop[4]+“+”+questionBot[4]+“=”+answers[4]+”正确答案是:“+Correct[4]);
写(“
”+questionTop[5]+“+”+questionBot[5]+“=”+answers[5]+”正确答案是:“+Correct[5]);
写(“
”+questionTop[6]+“+”+questionBot[6]+“=”+answers[6]+”正确答案是:“+Correct[6]);
写(“
”+questionTop[7]+“+”+questionBot[7]+“=”+answers[7]+”正确答案是:“+Correct[7]);
写(“
”+questionTop[8]+“+”+questionBot[8]+“=”+answers[8]+”正确答案是:“+Correct[8]);
写(“
”+questionTop[9]+“+”+questionBot[9]+“=”+answers[9]+”正确答案是:“+Correct[9]);
document.write(“
”+“你得到了“+correctAnswers+”10个答案中的正确答案”);//显示他们得到了多少个正确答案
document.write(“
”+“你得到了”+正确答案*10+%的正确答案。”);//计算他们的正确答案百分比
document.write(“
”+“新建测验”);//创建新按钮以重新加载屏幕并重新开始
文件。填写(“”);
}
如果我直接加载页面,它会正确显示。但作为一个iFrame,我得到的唯一结果是“你的答案:”。这仅适用于IE9、Chrome和FF工作
全文如下:
iFrame页面如下所示:
如果您输入10个答案,它应该会显示您的结果。我刚才在使用IE9时遇到了类似的问题-我的测试使用了一个本地文件,因此它的url开始文件://这似乎会导致IE9出现问题 我将其转换为使用
document.body.innerHTML+=“Hello IE9”代码>类型代码,它可以工作。如果我有更多的时间,我会使用createElement
等
当文档使用file:protocol document.write时,似乎真的会破坏DOM
您的站点正在使用http:,document.write代码似乎适合我,您是否使用file:
还有一点建议,就是不要使用文档。编写 这与Java无关:)您肯定缺少一个start-iframe标记。除此之外,不要使用文档。写,没有理由这样做。为什么要动态创建iframe?请查看链接。我添加了/iframe作为测试,但它没有解决问题。我应该把它从问题中删除,它不适用。