2014-09-20 69 views
0
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 = "[email protected]"; 
ilan.currentScore = "95"; 
ilan.newScore = "89"; 
ilan.changeScore("89"); 
console.log(ilan.currentScore); 
ilan.changeMail("[email protected]"); 
console.log(ilan.currentMail); 
var haim = new Human(); 
haim.name = "Haimon"; 
haim.currentMail="[email protected]"; 
haim.currentScore="54"; 
console.log(haim); 
haim.changeScore("77"); 
haim.changeMail("[email protected]"); 
haim.Xport(); 

这是一个JavaScript Obect Orientd文件试图从一个窗口中的另一个出口一些东西 之后收集他们从输入值在窗体或手动输入,我总是得到“Syntac错误的的Xport功能,它不是有效的,我在做什么错为什么它不让我使用窗口打开,我在做什么错?

+0

当然语法错误给你的行号?并在开发工具中的链接?并告诉你,意想不到的标记是'this'?任何合理的浏览器。 – 2014-09-20 11:39:06

+0

它告诉我,当我尝试调用该函数的位置时,该行在结尾处(haim.Xport(); – Ilan 2014-09-20 12:36:14

回答

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>"); 
         };       
}; 
+0

即使我只写了exporte.document.write(“b”); – Ilan 2014-09-20 11:56:25

+0

@ Ilan:呃,你只需要通过剩下的代码就可以搞清楚了,我停下了第一个明显的错误: – 2014-09-20 12:02:19

0

变化This.currentScorethis.currentScore并在字符串连接千万不要错过+

+0

它的问题我改变了代码在这里让你看看我试图做什么,我只用了exporte.document.writeln(“d”);并且仍然有Uncaught TypeError:undefined不是函数 – Ilan 2014-09-20 11:59:40

相关问题