日期:2014-05-17  浏览次数:20630 次

JS脚本在JSP页面显示问题
JSP页面,用以下代码点击查询的时候,时间只是显示一下,鼠标一松开,div显示的时间马上就消失了,这个是怎么回事?

<script type="text/javascript">
var now = "";
var date = new Date(); //日期对象
now = date.getFullYear()+"年"; 
now = now + (date.getMonth()+1)+"月"; 
now = now + date.getDate()+"日";
now = now + date.getHours()+"时";
now = now + date.getMinutes()+"分";
now = now + date.getSeconds()+"秒";
function queryStr(){
var query = document.getElementById("timeQuery");
query.innerHTML = now;
query.attributes(Style,"");
}
</script>

</head>

<body>
查询时间: <div id="timeQuery"></div>
<form action="***" method="post">
<input type="submit" value="查询" onclick="queryStr()"> <br><br>

  </form>
<br>
</body>

------解决方案--------------------
HTML code

<form action="***" method="post">
<input type="submit" value="查询" onclick="queryStr()"> <br><br>

------解决方案--------------------
提交了表单,页面就定向到action属性标明的URL,页面会被刷新~
你那显示的时间在原有的页面上………… 然后,就没有然后了~
------解决方案--------------------
探讨

就没有什么办法记录一下这个时间吗引用:
提交了表单,页面就定向到action属性标明的URL,页面会被刷新~
你那显示的时间在原有的页面上………… 然后,就没有然后了~

------解决方案--------------------
只要显示时间的话,没必要用form表单,如果一定要用的话,表单提交事件需要手动控制提交,在提交之前将获得的时间放在action的url后面,跳转页面通过irequest获得