2015-11-13 55 views
-5

我正在學習JavaScript和HTML,並且已經創建了一個網頁,其中添加了一個按鈕,單擊它可以提醒某些單詞。但它不是給alert.Please help.Here是我的代碼:Java腳本警報不起作用

<html> 
<head> 
<title> 
Pi^LaSa^ 
</title> 
<script type="text/javascript" > 
<!-- 
function developers(){ 
alert("The NaT Language was developed by Naman Chhaparia and Tanay Shankar,while sitting on the last bench of their former class 7 C while watching a boring dance practice !! 
Naman and Tanay are best friends, and currently study at St. Thomas School, Ranchi,one of the best schools of the whole of Eastern-India. ") 
} 
//--> 
</script> 
</head> 
<body> 
<h1><span style="font-size:28px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#FF0000;"><span style="font-size: 36px;"><strong>Pi<sup>^</sup></strong></span></span><span style="color:#40E0D0;"><span style="font-size: 36px;"><strong>La</strong></span></span><span style="color:#00FF00;"><span style="font-size: 36px;"><strong>Sa<sup>^</sup></strong></span></span></span></h1> 

<h2><span style="font-size:28px;"><span style="color:#00FF00;"><span style="font-size: 36px;"><strong><sup>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </sup></strong></span></span><span style="font-family:comic sans ms,cursive;"><span style="font-size: 36px;"><strong><sup><span style="font-size: 14px;">(The official website of the NaT Language)</span></sup></strong></span></span></span></h2> 

<p><span style="font-size:28px;"><span style="font-family:comic sans ms,cursive;"><span style="font-size: 36px;"><span style="font-size: 14px;"><span style="font-family:arial,helvetica,sans-serif;">Hello, guys !! Welcome to the official website of the NaT (Pi<sup>^</sup>LaSa<sup>^</sup>) language, which was developed by Naman Chhaparia (</span></span></span></span></span>Pi<sup>^</sup>LaPaLaPi&nbsp; Mi<sup>^</sup>NoNoLaTesLaMaLoLa) , and Tanay Shankar (Sa<sup>^</sup>LaPiLa Ax Ni<sup>^</sup>NoLaPiPoLaMa).</p> 

<p>&nbsp;</p> 

<input type="button" onclick="developers();" value="Learn about the Developers."> 
</body> 
</html> 
+1

http://stackoverflow.com/help/how-to-ask – LBes

+1

所以......你要我們寫一個語言處理系統適合你?祝你好運。 – David

+0

不是大衛,我只是想知道如何去做。我爲網上衝浪很多,但徒勞無功。 –

回答

2

不要開始寫使用長字符串的簡單腳本,如果你不知道如何使用它們。從小處開始,並建立它。

,問題是:https://jsfiddle.net/9mhtdssk/1/

保持簡單。下面的代碼的修改版本:

<html> 
 
<body> 
 

 
<input type="button" onclick="developers();" value="Learn about the Developers."> 
 
<script type="text/javascript"> 
 
    function developers() { 
 
    alert('Simple small string of text'); 
 
    } 
 
</script> 
 

 
</body> 
 
</html>

0

檢查it.You已經在工作alert.Its給予額外的空間。

<html> 
 
    <head> 
 
     <title> 
 
      Pi^LaSa^ 
 
     </title> 
 
     <script type="text/javascript" > 
 

 
      function developers() { 
 
       alert("The NaT Language was developed by Naman Chhaparia and Tanay Shankar,while sitting on the last bench of their former class 7 C while watching a boring dance practice !! Naman and Tanay are best friends,and currently study at St. Thomas School, Ranchi,one of the best schools of the whole of Eastern-India."); 
 

 
      } 
 

 
     </script> 
 
    </head> 
 
    <body> 
 
     <h1><span style="font-size:28px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#FF0000;"><span style="font-size: 36px;"><strong>Pi<sup>^</sup></strong></span></span><span style="color:#40E0D0;"><span style="font-size: 36px;"><strong>La</strong></span></span><span style="color:#00FF00;"><span style="font-size: 36px;"><strong>Sa<sup>^</sup></strong></span></span></span></h1> 
 

 
     <h2><span style="font-size:28px;"><span style="color:#00FF00;"><span style="font-size: 36px;"><strong><sup>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </sup></strong></span></span><span style="font-family:comic sans ms,cursive;"><span style="font-size: 36px;"><strong><sup><span style="font-size: 14px;">(The official website of the NaT Language)</span></sup></strong></span></span></span></h2> 
 

 
     <p><span style="font-size:28px;"><span style="font-family:comic sans ms,cursive;"><span style="font-size: 36px;"><span style="font-size: 14px;"><span style="font-family:arial,helvetica,sans-serif;">Hello, guys !! Welcome to the official website of the NaT (Pi<sup>^</sup>LaSa<sup>^</sup>) language, which was developed by Naman Chhaparia (</span></span></span></span></span>Pi<sup>^</sup>LaPaLaPi&nbsp; Mi<sup>^</sup>NoNoLaTesLaMaLoLa) , and Tanay Shankar (Sa<sup>^</sup>LaPiLa Ax Ni<sup>^</sup>NoLaPiPoLaMa).</p> 
 

 
     <p>&nbsp;</p> 
 

 
     <input type="button" onclick="developers();" value="Learn about the Developers."> 
 
    </body> 
 
</html>