JS编写的html文件,用浏览器打开后一片空白,没有要求输出的内容,不知道原因
希望有大神解惑,实在找不出错处。。下面是代码<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:/...
希望有大神解惑,实在找不出错处。。下面是代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
var students=new Array(["男","余剑烽"],["女","倪婷婷"],["男","冯超"],["男","刘培祥"],["男","周俊侠"],["男","张鸿斌"],["女","杨秀芝"],["男","王成"],["男","王晓阳"],["女","王知雨"],["男","申屠方伟"],["女","胡文琼"],["男","蒋骏斌"],["女","赵筱靓"],["男","邓驰"],["女","陈咿米"]);
function member(name,sex){ //自定义对象
this.name = name;
this.sex = sex;
this.display = display;
}
function display(){ //自定义函数
var str ="<font size=5 color=red>" + this.name +"</font>";
document.write("欢迎尊贵"+str+"的"+this.sex+"登陆本网站");
}
var i =parseInt(Math.random()*16);
var sex;
if (student[i][0] == "男")
sex = "先生";
else
sex = "女士";
member1=new member(students[i][1],sex); //创建对象
member1.display(); //调用对象方法
</script>
</body>
</html> 展开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<script type="text/javascript">
var students=new Array(["男","余剑烽"],["女","倪婷婷"],["男","冯超"],["男","刘培祥"],["男","周俊侠"],["男","张鸿斌"],["女","杨秀芝"],["男","王成"],["男","王晓阳"],["女","王知雨"],["男","申屠方伟"],["女","胡文琼"],["男","蒋骏斌"],["女","赵筱靓"],["男","邓驰"],["女","陈咿米"]);
function member(name,sex){ //自定义对象
this.name = name;
this.sex = sex;
this.display = display;
}
function display(){ //自定义函数
var str ="<font size=5 color=red>" + this.name +"</font>";
document.write("欢迎尊贵"+str+"的"+this.sex+"登陆本网站");
}
var i =parseInt(Math.random()*16);
var sex;
if (student[i][0] == "男")
sex = "先生";
else
sex = "女士";
member1=new member(students[i][1],sex); //创建对象
member1.display(); //调用对象方法
</script>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询