Javascript 为什么它不让我打开窗户,我做错了什么? 函数人(姓名、当前邮件、当前分数、新闻核心){ this.name=name | | document.queryselectoral('#e1')。value | |“输入名称”; this.currentMail=currentMail | | document.queryselectoral('#e2').value|| “输入电子邮件”; this.currentScore=currentScore | | document.querySelectorAll('#e3').value | “输入分数”; this.changeScore=函数(ns){ 如果(ns!=“”){ log(ns+“是您的新分数”); this.currentScore=ns;} }; this.changeMail=函数(cmail){ 如果(cmail!=“”){ log(cmail+“是您的新邮件”); this.currentMail=cmail}; }; this.Xport=function(){ var导出= 窗口打开(“,”MsgWindow“,”宽度=200,高度=100“); export.document.writeln(“
”+this.name+ “”+this.currentMail+ “+this.currentScore””; }; }; var ilan=新人类(); 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=新人类(); haim.name=“海门”; haim.currentMail=”ilanvac@013.net"; haim.currentScore=“54”; 控制台日志(haim); haim.changeScore(“77”); haim.changeMail(“haimvac@gmail.com"); haim.Xport(); 这是一个面向对象的JavaScript文件,它尝试在一个窗口之后将一些内容导出到另一个窗口Javascript 为什么它不让我打开窗户,我做错了什么? 函数人(姓名、当前邮件、当前分数、新闻核心){ this.name=name | | document.queryselectoral('#e1')。value | |“输入名称”; this.currentMail=currentMail | | document.queryselectoral('#e2').value|| “输入电子邮件”; this.currentScore=currentScore | | document.querySelectorAll('#e3').value | “输入分数”; this.changeScore=函数(ns){ 如果(ns!=“”){ log(ns+“是您的新分数”); this.currentScore=ns;} }; this.changeMail=函数(cmail){ 如果(cmail!=“”){ log(cmail+“是您的新邮件”); this.currentMail=cmail}; }; this.Xport=function(){ var导出= 窗口打开(“,”MsgWindow“,”宽度=200,高度=100“); export.document.writeln(“,javascript,export,Javascript,Export,”+this.name+ “”+this.currentMail+ “+this.currentScore””; }; }; var ilan=新人类(); ilan.name=“ilan Vachtel”; ilan.currentMail=”ilanvac@gmail.com"; ilan.currentScore=“95”; ilan.newScore=“89”; ilan.changeScore(“89”); console.log(i
从表单中的输入值或手动输入中收集它们,我总是得到“Xport函数中的Syntac错误,这是无效的,我做错了什么?在
此名称之前,您缺少一个+
:
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();
this.Xport=function(){
var导出=
窗口打开(“,”MsgWindow“,”宽度=200,高度=100“);
exporte.document.writeln(“”this.name+”+this.currentMail+
//这里-----------------------------------------------^
“+This.currentScore””;
};
};
将This.currentScore
更改为This.currentScore
,不要错过字符串concat中的+
。语法错误肯定是给了你行号?和开发工具中的行链接?并告诉你意外的标记是This
?任何合理的浏览器都会这样做。它告诉我,positi在上,当我尝试调用该函数时,该行位于末尾(haim.Xport();即使我只编写了export.document.write(“b”),这也不起作用@Ilan:好吧,你只需要把剩下的代码通读一遍就知道了。我在第一个明显的错误处停了下来。这不是问题。我在这里更改代码是为了让你看看我想做什么,我只用export.document.writeln(“d”)试过了,但仍然得到了未捕获的TypeError:undefined不是一个函数
this.Xport = function(){
var exporte=
window.open("", "MsgWindow", "width=200, height=100");
exporte.document.writeln("<p>" this.name +" "+this.currentMail+
// Here -----------------------------------------------^
" " + This.currentScore "</p>");
};
};