编写一个javascript程序完成以下功能:弹出窗口查询用户的生日,计算出用户的年龄并显示在浏览器的状态栏
展开全部
<script>
function open_()
{
var $_str="";
var $_b=document.body;
$_str+='<table id="js_date" width="365" style="position:absolute; left:'+(($_b.clientWidth-365)/2)+'px; top:200px; background-color:#dddddd" height="101" border="1"><tr><td colspan="3" align="center"><strong>年龄计算</strong></td></tr><tr><td width="102" align="center"><font size="2">请输入出生日期</font></td><td width="151"><input name="date_text" type="text" id="date_text" size="20" /></td><td width="90"><font color="#FF0000" size="2">* 1990/10/10</font></td></tr><tr><td> </td><td colspan="2"><input type="button" name="Submit" value=" 确认提交 " onclick="check_text()"/><input type="button" name="Submits" value=" 关闭程序 " onclick="close_();"/></td></tr></table>';
document.getElementById("map_").innerHTML=$_str;
}
function close_()
{
document.getElementById("map_").innerHTML="";
}
function check_text()
{
var d1=new Date(document.getElementById("date_text").value);
var d2=new Date();
var age=Math.ceil((d2-d1)/(365*24*60*60*1000));
var a="您的年龄是 "+age;
window.status=a;
}
</script>
<body><span id="map_"></span>
<input type="button" name="Submit" value=" 执行程序 " onclick="open_()" />
</body>
function open_()
{
var $_str="";
var $_b=document.body;
$_str+='<table id="js_date" width="365" style="position:absolute; left:'+(($_b.clientWidth-365)/2)+'px; top:200px; background-color:#dddddd" height="101" border="1"><tr><td colspan="3" align="center"><strong>年龄计算</strong></td></tr><tr><td width="102" align="center"><font size="2">请输入出生日期</font></td><td width="151"><input name="date_text" type="text" id="date_text" size="20" /></td><td width="90"><font color="#FF0000" size="2">* 1990/10/10</font></td></tr><tr><td> </td><td colspan="2"><input type="button" name="Submit" value=" 确认提交 " onclick="check_text()"/><input type="button" name="Submits" value=" 关闭程序 " onclick="close_();"/></td></tr></table>';
document.getElementById("map_").innerHTML=$_str;
}
function close_()
{
document.getElementById("map_").innerHTML="";
}
function check_text()
{
var d1=new Date(document.getElementById("date_text").value);
var d2=new Date();
var age=Math.ceil((d2-d1)/(365*24*60*60*1000));
var a="您的年龄是 "+age;
window.status=a;
}
</script>
<body><span id="map_"></span>
<input type="button" name="Submit" value=" 执行程序 " onclick="open_()" />
</body>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询