<html> <head> <mce:script type="text/javascript"><!-- function CTest(width, height) { this.m_nWidth=width; this.m_nHeight=height; } CTest.prototype= { m_nWidth: 0, m_nHeight: 0, m_pfnPrintInfo: function() { var strInfo = ""; strInfo += "width = " + this.m_nWidth + "\theight = " + this.m_nHeight + "\n"; alert(strInfo); } }; var objT1 = new CTest(1, 2); var objT2 = new CTest(12.3, 45.6); objT1.m_pfnPrintInfo(); objT2.m_pfnPrintInfo(); // --></mce:script> </head> <body οnlοad=""> <h1><font color="#ff0000">Test for new Object </font></h1> </body> </html>
JavaScript之构造函数
最新推荐文章于 2023-05-16 22:40:39 发布