在DW中编好的JS为什么在浏览器不能显示?
这是代码:<html><head><title>thebookofjavascript</title><scripttype="text/jsvascript"><!--...
这是代码:
<html>
<head><title>the book of javascript</title>
<script type ="text/jsvascript">
<!--
var date = new Date();
var month = date.getMonth();
var day = date.getDate();
var year = date.getYear();
var hour = date.getHours();
var minutes = date.getMinutes();
month = month + 1;
year =fixY2K(year);
minutes =fixTime(minutes);
var date_string = month +"/"+ day +"/"+ year;
var time_string = hour + ":" + minutes;
var date_time_string ="today is " + date_string +".the time is now"+ time_string +".";
function fixY2K(number){
if(number<1000){
number = number +1900;
}return number;
}
function fixTime(number){
if(number<10){
number = "0" + number;
}return number;
}
// -->
</script>
</head>
<body>
<h1>welcome to the book of javascript home page !</h1>
<script type ="text/javascript">
<!--
document.write(date_time_string);
// -->
</script>
</body>
</html> 展开
<html>
<head><title>the book of javascript</title>
<script type ="text/jsvascript">
<!--
var date = new Date();
var month = date.getMonth();
var day = date.getDate();
var year = date.getYear();
var hour = date.getHours();
var minutes = date.getMinutes();
month = month + 1;
year =fixY2K(year);
minutes =fixTime(minutes);
var date_string = month +"/"+ day +"/"+ year;
var time_string = hour + ":" + minutes;
var date_time_string ="today is " + date_string +".the time is now"+ time_string +".";
function fixY2K(number){
if(number<1000){
number = number +1900;
}return number;
}
function fixTime(number){
if(number<10){
number = "0" + number;
}return number;
}
// -->
</script>
</head>
<body>
<h1>welcome to the book of javascript home page !</h1>
<script type ="text/javascript">
<!--
document.write(date_time_string);
// -->
</script>
</body>
</html> 展开
展开全部
var date = new Date();
var month = date.getMonth();
var day = date.getDate();
var year = date.getYear();
var hour = date.getHours();
var minutes = date.getMinutes();
month = month + 1;
year =fixY2K(year);
minutes =fixTime(minutes);
var date_string = month +"/"+ day +"/"+ year;
var time_string = hour + ":" + minutes;
var date_time_string ="today is " + date_string +".the time is now"+ time_string +".";
把这段封装成js函数
function atime(){
var date = new Date();
var month = date.getMonth();
var day = date.getDate();
var year = date.getYear();
var hour = date.getHours();
var minutes = date.getMinutes();
month = month + 1;
year =fixY2K(year);
minutes =fixTime(minutes);
var date_string = month +"/"+ day +"/"+ year;
var time_string = hour + ":" + minutes;
return "today is " + date_string +".the time is now"+ time_string +".";
}
调用的时候:
<script type ="text/javascript">
<!--
document.write(atime())
// -->
</script>
var month = date.getMonth();
var day = date.getDate();
var year = date.getYear();
var hour = date.getHours();
var minutes = date.getMinutes();
month = month + 1;
year =fixY2K(year);
minutes =fixTime(minutes);
var date_string = month +"/"+ day +"/"+ year;
var time_string = hour + ":" + minutes;
var date_time_string ="today is " + date_string +".the time is now"+ time_string +".";
把这段封装成js函数
function atime(){
var date = new Date();
var month = date.getMonth();
var day = date.getDate();
var year = date.getYear();
var hour = date.getHours();
var minutes = date.getMinutes();
month = month + 1;
year =fixY2K(year);
minutes =fixTime(minutes);
var date_string = month +"/"+ day +"/"+ year;
var time_string = hour + ":" + minutes;
return "today is " + date_string +".the time is now"+ time_string +".";
}
调用的时候:
<script type ="text/javascript">
<!--
document.write(atime())
// -->
</script>
追问
在浏览器中还是只显示“welcome to the book of javascript home page !”
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询