1.Hello Word
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Hello World!</title> 5 </head> 6 <body> 7 <p>Hello World!</p> 8 <script type="text/javascript"> 9 </script> 10 </body> 11 </html>
2.
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Hello World!</title> 5 </head> 6 <body> 7 <p>Hello World!</p> 8 <input type="button" value="Click Me" onclick="showMessage()" /> 9 <input type="button" value="Click Me" onclick="sayHi()" /> 10 <script type="text/javascript"> 11 function showMessage(){ 12 alert("Hello world!"); 13 } 14 </script> 15 <script type="text/javascript" src="Hello.js"> </script> 16 </body> 17 </html>
1 function sayHi(){ 2 Person.prototype.name = "Nicholas"; 3 Person.prototype.age = 29; 4 Person.prototype.job = "Software Engineer"; 5 Person.prototype.sayName = function(){ 6 alert(this.name); 7 }; 8 var person = new Person(); 9 alert(person.name); 10 person.sayName(); 11 person.name = "Greg"; 12 } 13 function Person(){ 14 }