我寫它打印這是由它通過JavaScript渲染點擊一個按鈕觸發了DOM的某一區域的功能請參見下面的代碼...獲得「未捕獲的SyntaxError:意外的標記}
function MarkQuiz() {
var CorrectAnswers = 0,
TotalQuestions = 0,
CurrentQuestion = "",
Percentage = 0,
Output = "";
$("select").each(function(key,value) {
CurrentQuestion = "#" + $(value).attr("id");
TotalQuestions = key + 1;
if($(CurrentQuestion).val() == "Correct") {
CorrectAnswers++;
}
});
Percentage = (CorrectAnswers/TotalQuestions) * 100;
Output = "You Scored..." +
"<h1>"+Percentage+"%</h1>" +
"Which means you got " + CorrectAnswers + " out of " + TotalQuestions + " correct.<br/>" +
"<br/><a href='#' onclick='PrintCertificate('#QuizMainContent')' class='button' id='PrintCertificate'>Print your Certificate</a>";
$("#QuizMainContent").html(Output);
}
function PrintCertificate(DOMArea) {
var PrintArea = $(DOMArea),
PrintWindow = window.open('','');
PrintWindow.document.write($(PrintArea).html());
PrintWindow.document.close();
PrintWindow.focus();
PrintWindow.print();
PrintWindow.close();
}
這是URL到項目:http://historicalperiods.esy.es/
我在做什麼錯在ADVA 謝謝NCE。
好心分享URL,因爲它不是文件的問題,但帶有URL –
那麼,當你點擊它提供給你的方便鏈接時會出現什麼代碼? –
錯誤消息說錯誤來自不同的文件。點擊控制檯中的鏈接轉到該文件。 – Quentin