标签:实例化 教程 date line 1.4 种类型 oct rip 操作
一. 使用JavaScript对象
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>使用自定义对象</title> 5 <script type="text/javascript"> 6 function show_book() { //定义方法所对应的函数 7 document.write("<H1>书名:" + this.title + "</H1>"); 8 document.write("<H1>作者:" + this.author + "</H1>"); 9 document.write("<H1>出版社:" + this.publisher + "</H1>"); 10 } 11 function Book(title,author,publisher) { //构造函数 12 this.title = title; 13 this.author = author; 14 this.publisher = publisher; 15 this.show_book = show_book; 16 } 17 </script> 18 </head> 19 <body> 20 <script type="text/javascript"> 21 MyBook = new Book("JavaScript实例教程" , "赵丰年" , "电子工业出版社"); //实例化对象 22 MyBook.show_book(); //引用对象方法 23 document.write("<br><br><H2>谁是" + MyBook.author + "?</H2>"); //引用对象属性 24 </script> 25 </body> 26 </html>
标签:实例化 教程 date line 1.4 种类型 oct rip 操作
原文地址:http://www.cnblogs.com/luckyliulin/p/7392623.html