主题:javascript代码问题
我的代码实现不了 不知道是什么问题 谁帮忙解决一下
<script language="javascript">
document.write("<hr />");
document.write("<h3>示例 3.2 创建对象</h3>");
document.write("<hr />");
U = new Company("IC网络公司", "北京", "January 05,1997 12:00:00", "http://www.baidu.com");
U["Name"] = "北京";
U["city"] = "海淀区";
U["Date"] = "1999";
function showCompany()
{
for(var prop in this)
{
alert(prop += " " + this[prop] + " ");
}
}
function Company(name, city, createDate, URL)
{
this.Name = name;
this.city = city;
this.createDate = new Date(createDate);
this.URL = URL;
this.showCompany = showCompany;
}
document.write("<input type = 'button' value = '对象定义' onClick = 'showCompany(U)'>");
</script>
<script language="javascript">
document.write("<hr />");
document.write("<h3>示例 3.2 创建对象</h3>");
document.write("<hr />");
U = new Company("IC网络公司", "北京", "January 05,1997 12:00:00", "http://www.baidu.com");
U["Name"] = "北京";
U["city"] = "海淀区";
U["Date"] = "1999";
function showCompany()
{
for(var prop in this)
{
alert(prop += " " + this[prop] + " ");
}
}
function Company(name, city, createDate, URL)
{
this.Name = name;
this.city = city;
this.createDate = new Date(createDate);
this.URL = URL;
this.showCompany = showCompany;
}
document.write("<input type = 'button' value = '对象定义' onClick = 'showCompany(U)'>");
</script>