2014-09-20 71 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

相關問題