function Human(name,currentMail,currentScore,newScore){
this.name=name || document.querySelectorAll('#e1').value || "Enter Name";
this.currentMail= currentMail || document.querySelectorAll('#e2').value ||
"Enter Email";
this.currentScore=currentScore || document.querySelectorAll('#e3').value ||
"Enter Score";
this.changeScore = function(ns){
if (ns!=""){
console.log(ns+" Is Your New Score");
this.currentScore=ns;}
};
this.changeMail = function(cmail){
if(cmail!=""){
console.log(cmail + " Is Your New Mail");
this.currentMail = cmail};
};
this.Xport = function(){
var exporte=
window.open("", "MsgWindow", "width=200, height=100");
exporte.document.writeln("<p>"+ this.name +
" "+this.currentMail+
" " + this.currentScore "</p>");
};
};
var ilan = new Human();
ilan.name= "ilan Vachtel";
ilan.currentMail = "ilanvac@gmail.com";
ilan.currentScore = "95";
ilan.newScore = "89";
ilan.changeScore("89");
console.log(ilan.currentScore);
ilan.changeMail("ilanvac@013.net");
console.log(ilan.currentMail);
var haim = new Human();
haim.name = "Haimon";
haim.currentMail="ilanvac@013.net";
haim.currentScore="54";
console.log(haim);
haim.changeScore("77");
haim.changeMail("haimvac@gmail.com");
haim.Xport();
这是JavaScript中的一个Obect Oriented文件,尝试将一些窗口中的一些东西导出到另一个窗口之后 从输入值中收集它们在表单或手动输入中,我总是得到“Xport函数中的语法错误,它无效,我做错了什么?”
答案 0 :(得分:0)
您在+
之前错过了this.name
:
this.Xport = function(){
var exporte=
window.open("", "MsgWindow", "width=200, height=100");
exporte.document.writeln("<p>" this.name +" "+this.currentMail+
// Here -----------------------------------------------^
" " + This.currentScore "</p>");
};
};
答案 1 :(得分:0)
将This.currentScore
更改为this.currentScore
,不要错过字符串concat中的+
。