我有一个用于输入文本的LMS课程。我希望他们能够打印或通过电子邮件发送自己的笔记。我在课程中有一段javascript打开一个新的html窗口,它使用html,css和js。格式化页面并从课程中调用变量。
我成功设置了打印按钮,但是当我尝试重新编写电子邮件选项的脚本时。根本不起作用。我不确定我错过了什么/做错了什么。我将发布打印按钮和非工作脚本的工作javascript。
/This will get the current date for the user
var d = new Date(),curr_date = d.getDate(),curr_month = d.getMonth() + 1,curr_year = d.getFullYear();
var player = opener?opener.GetPlayer():{} ;
/* ------------------ this is ONLY for debugging ----------- */
if (!player.GetVar) player={
GetVar : function(idx) {
return {printTitle:"Please access this workbook from within the module", printUserName:"Unknown"}[idx]
}
}
/* ------------------ the above is ONLY for debugging ----------- */
$(function() {
if (window.print) {
$("#print").text("Print").on("click",function() { window.focus(); window.print() })
$("#printDiv").show();
}
var title = player.GetVar("printTitle"), userName = player.GetVar("printUserName");
$("#title").html(title);
$("#userName").html(userName);
$("#date").html(curr_month + "-" + curr_date + "-" + curr_year);
var numberOfAnswers = $(".answer").length;
for (var i=1;i<=numberOfAnswers;i++) {
var $content = $("#answer"+i);
var q = player.GetVar("Q"+i);
q=q?q.replace(/\n/g,"<br/>"):"No response provided."
// window.console && console.log(q);
$content.append("<p>"+(q)+"</p>");
}
});
破碎的代码
$(function(){
if (window.email) {
$(".SendEmail").text("Email").click(function(event)
Var email="emailaddress";
var subject="Module 5 Reflections";
var email body="content";
var attach= "path";
document.location= "mailto:"+email+"?subject="+subject+"&body="+emailbody+"?attach=
});
]);
}
var useremail= player.GetVar("emailaddress");
$("#title").html(title);
$("#emailaddress").html(emailaddress);
$("#date").html(curr_month + "-" + curr_date + "-" + curr_year);
var numberOfAnswers = $(".answer").length;
for (var i=1;i<=numberOfAnswers;i++) {
var $content = $("#answer"+i);
var q = player.GetVar("Q"+i);
q=q?q.replace(/\n/g,"<br/>"):"No response provided."
// window.console && console.log(q);
$content.append("<p>"+(q)+"</p>");
}
});